atquery 2.12.2__tar.gz → 2.12.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {atquery-2.12.2 → atquery-2.12.4}/PKG-INFO +1 -1
- atquery-2.12.2/pyproject.toml.orig → atquery-2.12.4/pyproject.toml +1 -1
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/diff.py +2 -2
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/diff/parser.py +36 -0
- atquery-2.12.2/pyproject.toml +0 -121
- {atquery-2.12.2 → atquery-2.12.4}/LICENSE +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/README.md +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/aio/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/aio/engine.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/aio/query.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/api_v2.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/atquery2.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/columns.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/ddl.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/ecd.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/main.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/migrate.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/routines.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/scenario.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/schemas.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/cli/tables.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/duckdb.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/aio.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/core.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/dump/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/dump/__main__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/dump/core.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/meta.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/pooling.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/restore/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/restore/__main__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/mysql/restore/core.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/dialect/sqlite.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/diff/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/diff/comparator.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/diff/generator.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/diff/git_integration.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/diff/models.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/_toml.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/catalog.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/ddl.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/diff.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/erd.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/errors.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/model.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/parser.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/resolver.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/ecd/skeleton.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/engine.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/factory.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/migration/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/migration/_migrator.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/migration/_protocol.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/migration/_standard.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/migration/_types.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/py.typed +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/testing/__init__.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/testing/creator.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/testing/loader.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/testing/schema.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/testing/validator.py +0 -0
- {atquery-2.12.2 → atquery-2.12.4}/src/atquery/type.py +0 -0
|
@@ -146,8 +146,8 @@ def execute_diff(args: argparse.Namespace) -> int:
|
|
|
146
146
|
|
|
147
147
|
old_tables = parse_file(old_path, dialect=args.dialect)
|
|
148
148
|
new_tables = parse_file(new_path, dialect=args.dialect)
|
|
149
|
-
elif args.datasource is not None:
|
|
150
|
-
# ---
|
|
149
|
+
elif args.datasource is not None or args.schema is not None:
|
|
150
|
+
# --- データソースモード(--schema指定時は--datasource省略でも環境変数にフォールバックする) ---
|
|
151
151
|
datasource_uri = args.datasource or os.environ.get("ATQUERY_DATASOURCE")
|
|
152
152
|
if not datasource_uri:
|
|
153
153
|
print(
|
|
@@ -98,15 +98,51 @@ def parse_sql(sql: str, dialect: str = "mysql", *, normalize_mysql_defaults: boo
|
|
|
98
98
|
"""
|
|
99
99
|
stmts = sqlglot.parse(sql, dialect=dialect, error_level=sqlglot.ErrorLevel.IGNORE)
|
|
100
100
|
tables: dict[str, TableDef] = {}
|
|
101
|
+
index_stmts: list[exp.Create] = []
|
|
101
102
|
for stmt in stmts:
|
|
102
103
|
if stmt is None:
|
|
103
104
|
continue
|
|
104
105
|
if isinstance(stmt, exp.Create) and stmt.kind == "TABLE":
|
|
105
106
|
table_def = _parse_create_table(stmt, dialect=dialect, normalize_mysql_defaults=normalize_mysql_defaults)
|
|
106
107
|
tables[table_def.name] = table_def
|
|
108
|
+
elif isinstance(stmt, exp.Create) and stmt.kind == "INDEX":
|
|
109
|
+
index_stmts.append(stmt)
|
|
110
|
+
|
|
111
|
+
# CREATE TABLE より後方に書かれている前提の単独INDEX文を、対象テーブルが出揃った後にまとめて反映する
|
|
112
|
+
for stmt in index_stmts:
|
|
113
|
+
_apply_standalone_create_index(stmt, tables)
|
|
114
|
+
|
|
107
115
|
return tables
|
|
108
116
|
|
|
109
117
|
|
|
118
|
+
def _apply_standalone_create_index(stmt: exp.Create, tables: dict[str, TableDef]) -> None:
|
|
119
|
+
"""`CREATE [UNIQUE] INDEX name ON table (...)` 単独文を対象テーブルのindexes一覧に追加する。
|
|
120
|
+
|
|
121
|
+
対象テーブルが同じSQL中に無い場合(別ファイル定義など)は何もしない。
|
|
122
|
+
"""
|
|
123
|
+
index_expr = stmt.this
|
|
124
|
+
if not isinstance(index_expr, exp.Index):
|
|
125
|
+
return
|
|
126
|
+
table_ref = index_expr.args.get("table")
|
|
127
|
+
if table_ref is None:
|
|
128
|
+
return
|
|
129
|
+
table_def = tables.get(table_ref.name)
|
|
130
|
+
if table_def is None:
|
|
131
|
+
return
|
|
132
|
+
|
|
133
|
+
name_ident = index_expr.this
|
|
134
|
+
index_name = name_ident.name if name_ident else None
|
|
135
|
+
columns: list[str] = []
|
|
136
|
+
params = index_expr.args.get("params")
|
|
137
|
+
if params is not None:
|
|
138
|
+
for col_expr in params.args.get("columns") or []:
|
|
139
|
+
col = col_expr.find(exp.Column)
|
|
140
|
+
if col is not None:
|
|
141
|
+
columns.append(col.name)
|
|
142
|
+
kind = "UNIQUE" if stmt.args.get("unique") else "INDEX"
|
|
143
|
+
table_def.indexes.append(IndexDef(name=index_name, kind=kind, columns=columns))
|
|
144
|
+
|
|
145
|
+
|
|
110
146
|
def _parse_create_table(
|
|
111
147
|
stmt: exp.Create, dialect: str = "mysql", *, normalize_mysql_defaults: bool = False
|
|
112
148
|
) -> TableDef:
|
atquery-2.12.2/pyproject.toml
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["uv_build>=0.11.15,<0.12"]
|
|
3
|
-
build-backend = "uv_build"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "atquery"
|
|
7
|
-
version = "2.12.2"
|
|
8
|
-
description = "A Python module for simplifying DBAPI usage with one-query-per-file SQL management."
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.10"
|
|
11
|
-
license = "MIT"
|
|
12
|
-
license-files = ["LICENSE"]
|
|
13
|
-
dependencies = ["tomli>=2.0.1; python_version < '3.11'"]
|
|
14
|
-
keywords = [
|
|
15
|
-
"sql",
|
|
16
|
-
"database",
|
|
17
|
-
"dbapi",
|
|
18
|
-
"mysql",
|
|
19
|
-
"sqlite",
|
|
20
|
-
"duckdb",
|
|
21
|
-
]
|
|
22
|
-
classifiers = [
|
|
23
|
-
"Development Status :: 4 - Beta",
|
|
24
|
-
"Intended Audience :: Developers",
|
|
25
|
-
"Programming Language :: Python :: 3",
|
|
26
|
-
"Programming Language :: Python :: 3 :: Only",
|
|
27
|
-
"Programming Language :: Python :: 3.10",
|
|
28
|
-
"Programming Language :: Python :: 3.11",
|
|
29
|
-
"Programming Language :: Python :: 3.12",
|
|
30
|
-
"Programming Language :: Python :: 3.13",
|
|
31
|
-
"Topic :: Database",
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
[[project.authors]]
|
|
35
|
-
name = "alpine"
|
|
36
|
-
|
|
37
|
-
[project.scripts]
|
|
38
|
-
atquery = "atquery.cli.main:main"
|
|
39
|
-
|
|
40
|
-
[project.optional-dependencies]
|
|
41
|
-
mysql = ["mysql-connector-python>=8.0,<10"]
|
|
42
|
-
duckdb = ["duckdb>=0.10.0"]
|
|
43
|
-
testing = ["json5>=0.12.1"]
|
|
44
|
-
diff = ["sqlglot>=30.4.2"]
|
|
45
|
-
all = [
|
|
46
|
-
"mysql-connector-python",
|
|
47
|
-
"duckdb",
|
|
48
|
-
"json5",
|
|
49
|
-
"sqlglot",
|
|
50
|
-
"python-dotenv>=1.2.2",
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
[dependency-groups]
|
|
54
|
-
dev = [
|
|
55
|
-
"mysql-connector-python",
|
|
56
|
-
"duckdb",
|
|
57
|
-
"json5",
|
|
58
|
-
"python-dotenv",
|
|
59
|
-
"sqlglot",
|
|
60
|
-
"ruff",
|
|
61
|
-
"pyright",
|
|
62
|
-
"pytest>=7.0.0",
|
|
63
|
-
"pytest-cov>=4.0.0",
|
|
64
|
-
"pytest-mock>=3.10.0",
|
|
65
|
-
"pyyaml>=6.0.3",
|
|
66
|
-
"rich>=14.3.3",
|
|
67
|
-
"pytest-asyncio>=1.4.0",
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
[tool.uv]
|
|
71
|
-
package = true
|
|
72
|
-
|
|
73
|
-
[tool.ruff]
|
|
74
|
-
src = ["src"]
|
|
75
|
-
|
|
76
|
-
[tool.ruff.lint]
|
|
77
|
-
select = [
|
|
78
|
-
"E2",
|
|
79
|
-
"E4",
|
|
80
|
-
"E7",
|
|
81
|
-
"E9",
|
|
82
|
-
"W",
|
|
83
|
-
"F",
|
|
84
|
-
"INP",
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
[tool.ruff.lint.per-file-ignores]
|
|
88
|
-
"docker/*.py" = ["INP"]
|
|
89
|
-
"scripts/*.py" = ["INP"]
|
|
90
|
-
"tests/*.py" = ["INP"]
|
|
91
|
-
"var/*.py" = ["INP"]
|
|
92
|
-
|
|
93
|
-
[tool.pyright]
|
|
94
|
-
include = ["src"]
|
|
95
|
-
venvPath = "."
|
|
96
|
-
venv = ".venv"
|
|
97
|
-
typeCheckingMode = "basic"
|
|
98
|
-
|
|
99
|
-
[tool.pytest.ini_options]
|
|
100
|
-
cache_dir = "var/.pytest_cache"
|
|
101
|
-
asyncio_mode = "auto"
|
|
102
|
-
testpaths = ["tests"]
|
|
103
|
-
|
|
104
|
-
[tool.coverage.run]
|
|
105
|
-
source = ["src"]
|
|
106
|
-
data_file = "var/.coverage"
|
|
107
|
-
omit = ["tests/*"]
|
|
108
|
-
|
|
109
|
-
[tool.coverage.report]
|
|
110
|
-
exclude_lines = [
|
|
111
|
-
"pragma: no cover",
|
|
112
|
-
"def __repr__",
|
|
113
|
-
"if self.debug:",
|
|
114
|
-
"if settings.DEBUG",
|
|
115
|
-
"raise AssertionError",
|
|
116
|
-
"raise NotImplementedError",
|
|
117
|
-
"if 0:",
|
|
118
|
-
"if __name__ == .__main__.:",
|
|
119
|
-
'class .*\bProtocol\):',
|
|
120
|
-
'@(abc\.)?abstractmethod',
|
|
121
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|