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:
@@ -2,41 +2,9 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from aerich.ddl.sqlite import SqliteDDL
|
||||
from aerich.migrate import Migrate
|
||||
from tests._utils import chdir, copy_files, run_shell
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def new_aerich_project(tmp_path: Path):
|
||||
test_dir = Path(__file__).parent
|
||||
asset_dir = test_dir / "assets" / "fake"
|
||||
settings_py = asset_dir / "settings.py"
|
||||
_tests_py = asset_dir / "_tests.py"
|
||||
db_py = asset_dir / "db.py"
|
||||
models_py = test_dir / "models.py"
|
||||
models_second_py = test_dir / "models_second.py"
|
||||
copy_files(settings_py, _tests_py, models_py, models_second_py, db_py, target_dir=tmp_path)
|
||||
dst_dir = tmp_path / "tests"
|
||||
dst_dir.mkdir()
|
||||
dst_dir.joinpath("__init__.py").touch()
|
||||
copy_files(test_dir / "_utils.py", test_dir / "indexes.py", target_dir=dst_dir)
|
||||
if should_remove := str(tmp_path) not in sys.path:
|
||||
sys.path.append(str(tmp_path))
|
||||
with chdir(tmp_path):
|
||||
run_shell("python db.py create", capture_output=False)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if not os.getenv("AERICH_DONT_DROP_FAKE_DB"):
|
||||
run_shell("python db.py drop", capture_output=False)
|
||||
if should_remove:
|
||||
sys.path.remove(str(tmp_path))
|
||||
from tests._utils import Dialect, run_shell
|
||||
|
||||
|
||||
def _append_field(*files: str, name="field_1") -> None:
|
||||
@@ -48,7 +16,7 @@ def _append_field(*files: str, name="field_1") -> None:
|
||||
|
||||
|
||||
def test_fake(new_aerich_project):
|
||||
if (ddl := getattr(Migrate, "ddl", None)) and isinstance(ddl, SqliteDDL):
|
||||
if Dialect.is_sqlite():
|
||||
# TODO: go ahead if sqlite alter-column supported
|
||||
return
|
||||
output = run_shell("aerich init -t settings.TORTOISE_ORM")
|
||||
|
||||
Reference in New Issue
Block a user