Merge remote-tracking branch 'upstream/dev' into update-changelog
This commit is contained in:
commit
27b29e401b
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -21,6 +21,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Start MySQL
|
- name: Start MySQL
|
||||||
run: sudo systemctl start mysql.service
|
run: sudo systemctl start mysql.service
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
|
2
Makefile
2
Makefile
@ -22,6 +22,8 @@ style: deps _style
|
|||||||
_check:
|
_check:
|
||||||
@black --check $(black_opts) $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
|
@black --check $(black_opts) $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
|
||||||
@ruff check $(checkfiles)
|
@ruff check $(checkfiles)
|
||||||
|
@mypy $(checkfiles)
|
||||||
|
@bandit -r aerich
|
||||||
check: deps _check
|
check: deps _check
|
||||||
|
|
||||||
test: deps
|
test: deps
|
||||||
|
@ -135,7 +135,7 @@ class BaseDDL:
|
|||||||
self.schema_generator._column_comment_generator(
|
self.schema_generator._column_comment_generator(
|
||||||
table=db_table,
|
table=db_table,
|
||||||
column=db_column,
|
column=db_column,
|
||||||
comment=field_describe.get("description"),
|
comment=description,
|
||||||
)
|
)
|
||||||
if description
|
if description
|
||||||
else ""
|
else ""
|
||||||
|
@ -56,7 +56,7 @@ from information_schema.constraint_column_usage const
|
|||||||
right join information_schema.columns c using (column_name, table_catalog, table_schema, table_name)
|
right join information_schema.columns c using (column_name, table_catalog, table_schema, table_name)
|
||||||
where c.table_catalog = $1
|
where c.table_catalog = $1
|
||||||
and c.table_name = $2
|
and c.table_name = $2
|
||||||
and c.table_schema = $3"""
|
and c.table_schema = $3""" # nosec:B608
|
||||||
ret = await self.conn.execute_query_dict(sql, [self.database, table, self.schema])
|
ret = await self.conn.execute_query_dict(sql, [self.database, table, self.schema])
|
||||||
for row in ret:
|
for row in ret:
|
||||||
columns.append(
|
columns.append(
|
||||||
|
@ -4,7 +4,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional, Union
|
||||||
|
|
||||||
from click import BadOptionUsage, ClickException, Context
|
from click import BadOptionUsage, ClickException, Context
|
||||||
from tortoise import BaseDBAsyncClient, Tortoise
|
from tortoise import BaseDBAsyncClient, Tortoise
|
||||||
@ -95,7 +95,7 @@ def is_default_function(string: str) -> Optional[re.Match]:
|
|||||||
return re.match(r"^<function.+>$", str(string or ""))
|
return re.match(r"^<function.+>$", str(string or ""))
|
||||||
|
|
||||||
|
|
||||||
def import_py_file(file: Path) -> ModuleType:
|
def import_py_file(file: Union[str, Path]) -> ModuleType:
|
||||||
module_name, file_ext = os.path.splitext(os.path.split(file)[-1])
|
module_name, file_ext = os.path.splitext(os.path.split(file)[-1])
|
||||||
spec = importlib.util.spec_from_file_location(module_name, file)
|
spec = importlib.util.spec_from_file_location(module_name, file)
|
||||||
module = importlib.util.module_from_spec(spec) # type:ignore[arg-type]
|
module = importlib.util.module_from_spec(spec) # type:ignore[arg-type]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import List, cast
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import tortoise
|
import tortoise
|
||||||
@ -792,13 +793,13 @@ old_models_describe = {
|
|||||||
|
|
||||||
|
|
||||||
def should_add_user_id_column_type_alter_sql() -> bool:
|
def should_add_user_id_column_type_alter_sql() -> bool:
|
||||||
|
if tortoise.__version__ < "0.21":
|
||||||
|
return False
|
||||||
# tortoise-orm>=0.21 changes IntField constraints
|
# tortoise-orm>=0.21 changes IntField constraints
|
||||||
# from {"ge": 1, "le": 2147483647} to {"ge": -2147483648,"le": 2147483647}
|
# from {"ge": 1, "le": 2147483647} to {"ge": -2147483648,"le": 2147483647}
|
||||||
user_id_constraints = old_models_describe["models.Category"]["data_fields"][-1]["constraints"]
|
data_fields = cast(List[dict], old_models_describe["models.Category"]["data_fields"])
|
||||||
return (
|
user_id_constraints = data_fields[-1]["constraints"]
|
||||||
tortoise.__version__ >= "0.21"
|
return tortoise.fields.data.IntField.constraints != user_id_constraints
|
||||||
and tortoise.fields.data.IntField.constraints != user_id_constraints
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_migrate(mocker: MockerFixture):
|
def test_migrate(mocker: MockerFixture):
|
||||||
@ -825,6 +826,7 @@ def test_migrate(mocker: MockerFixture):
|
|||||||
if isinstance(Migrate.ddl, SqliteDDL):
|
if isinstance(Migrate.ddl, SqliteDDL):
|
||||||
with pytest.raises(NotSupportError):
|
with pytest.raises(NotSupportError):
|
||||||
Migrate.diff_models(old_models_describe, models_describe)
|
Migrate.diff_models(old_models_describe, models_describe)
|
||||||
|
with pytest.raises(NotSupportError):
|
||||||
Migrate.diff_models(models_describe, old_models_describe, False)
|
Migrate.diff_models(models_describe, old_models_describe, False)
|
||||||
else:
|
else:
|
||||||
Migrate.diff_models(old_models_describe, models_describe)
|
Migrate.diff_models(old_models_describe, models_describe)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from aerich.utils import import_py_file
|
from aerich.utils import import_py_file
|
||||||
|
|
||||||
|
|
||||||
def test_import_py_file():
|
def test_import_py_file() -> None:
|
||||||
m = import_py_file("aerich/utils.py")
|
m = import_py_file("aerich/utils.py")
|
||||||
assert getattr(m, "import_py_file")
|
assert getattr(m, "import_py_file")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user