fix: inspectdb not match data type 'DOUBLE' and 'CHAR' for MySQL
* increase: 1. Inspectdb adds DECIMAL, DOUBLE, CHAR, TIME data type matching; 2. Add exception handling, avoid the need to manually create the entire table because a certain data type is not supported. * fix: aerich inspectdb raise KeyError for double in MySQL * feat: support command `python -m aerich` * docs: update changelog * tests: verify mysql inspectdb for float field * fix mysql uuid field inspect to be charfield * refactor: use `db_index=True` instead of `index=True` for inspectdb * docs: update changelog --------- Co-authored-by: xiechen <xiechen@jinse.com> Co-authored-by: Waket Zheng <waketzheng@gmail.com>
This commit is contained in:
17
tests/test_inspectdb.py
Normal file
17
tests/test_inspectdb.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from tests._utils import Dialect, run_shell
|
||||
|
||||
|
||||
def test_inspect(new_aerich_project):
|
||||
if Dialect.is_sqlite():
|
||||
# TODO: test sqlite after #384 fixed
|
||||
return
|
||||
run_shell("aerich init -t settings.TORTOISE_ORM")
|
||||
run_shell("aerich init-db")
|
||||
ret = run_shell("aerich inspectdb -t product")
|
||||
assert ret.startswith("from tortoise import Model, fields")
|
||||
assert "primary_key=True" in ret
|
||||
assert "fields.DatetimeField" in ret
|
||||
assert "fields.FloatField" in ret
|
||||
assert "fields.UUIDField" in ret
|
||||
if Dialect.is_mysql():
|
||||
assert "db_index=True" in ret
|
||||
Reference in New Issue
Block a user