mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-17 03:31:59 +00:00
合入集成分支(阶段 2A 数据剖析、4B 剖析与 SQL 检查界面及修正)到 4A:两边功能都保留
冲突的解法: - 后端 api/catalog.py:同时导入 catalog_impact 和 catalog_profile、SnapshotTampered;data/catalog.py:__all__ 取两边的并集重排。 - 2A 放宽了码值校验(含义可以为空,剖析写进来的是「含义待填写」):目录修改提案的码值补充改为含义为空的码不覆盖已有含义、 只在原来没有这个码时加进去,补了测试;卡片和过程里的码值把空含义写成「含义待填写」,和目录页同一个说法。 - 前端 types.ts、terms.ts:两边各在同一处追加了新段落,按顺序都留下(提案、影响面、目录版本在前,剖析、码值、SQL 检查在后), 没有重复的键;client.ts、decode.ts、CatalogPage.tsx、TableDetail.tsx 的导入取并集。 - check-catalog.mjs:影响面和剖析、保存数据源三条假路由都留下,各节和最后核对真库数量的逻辑不变。 - 4A 的测试数据源改用 tests/fixtures/sources.py 的 drop_source 删除,顺带作废连接池。
This commit is contained in:
@@ -25,6 +25,7 @@ from app.data import catalog
|
||||
from app.data.engine import engines
|
||||
from app.data.introspect import introspect
|
||||
from tests.fixtures.catalog import scenic_notes
|
||||
from tests.fixtures.sources import drop_source
|
||||
|
||||
_CACHE: dict[str, dict] = {}
|
||||
|
||||
@@ -76,6 +77,32 @@ async def test_codes_are_supplemented_not_replaced(scenic_db):
|
||||
assert change.value == {"9": "作废"}
|
||||
|
||||
|
||||
async def test_codes_with_pending_meanings(scenic_db):
|
||||
"""数据剖析写进来的码值候选含义为空(界面上写「含义待填写」):提案可以补上含义;提案里含义为空的码只在原来
|
||||
没有时加进去,不抹掉已有的含义;含义为空的码合法,保存不报错。"""
|
||||
tables = (await _schema(scenic_db))["tables"]
|
||||
profiled = _visits()
|
||||
profiled["columns"]["status"]["codes"] = catalog.make_item({"1": "有效", "0": "", "9": ""}, "profile", "proposed")
|
||||
plan = catalog.plan_patch(profiled, [{"path": "columns.status.codes", "value": {"9": "作废", "1": ""}}],
|
||||
table="visits", tables=tables)
|
||||
assert plan.problems == []
|
||||
[change] = plan.changes
|
||||
assert change.after == {"1": "有效", "0": "", "9": "作废"} and change.state == "change"
|
||||
# 只给了含义为空的新码:照样加进去,含义待人填
|
||||
plan = catalog.plan_patch(profiled, [{"path": "columns.status.codes", "value": {"7": ""}}], table="visits",
|
||||
tables=tables)
|
||||
assert plan.changes[0].after == {"1": "有效", "0": "", "9": "", "7": ""}
|
||||
# 只给了含义为空的已有码:什么都没变,这一项是「保存即确认」(原来是推断)
|
||||
plan = catalog.plan_patch(profiled, [{"path": "columns.status.codes", "value": {"1": ""}}], table="visits",
|
||||
tables=tables)
|
||||
assert plan.changes[0].state == "confirm"
|
||||
out = catalog.apply_patch(profiled, [{"path": "columns.status.codes", "value": {"9": "作废"}}], table="visits",
|
||||
tables=tables)
|
||||
codes = out["columns"]["status"]["codes"]
|
||||
assert codes["value"] == {"1": "有效", "0": "", "9": "作废"} and (codes["source"], codes["status"]) == (
|
||||
"human", "confirmed")
|
||||
|
||||
|
||||
async def test_new_relation_gets_its_id_from_both_ends(scenic_db):
|
||||
tables = (await _schema(scenic_db))["tables"]
|
||||
value = {"columns": ["visit_id"], "to_table": "visits", "to_columns": ["id"], "cardinality": "many_to_one"}
|
||||
@@ -190,11 +217,7 @@ async def scenic_source(scenic_db):
|
||||
await catalog.write_entry(session, row.id, table, notes, if_version=0, actor="王敏")
|
||||
source_id = row.id
|
||||
yield SimpleNamespace(id=source_id, name=name)
|
||||
async with SessionLocal() as session:
|
||||
row = await session.get(DataSource, source_id)
|
||||
if row is not None:
|
||||
await session.delete(row)
|
||||
await session.commit()
|
||||
await drop_source(source_id)
|
||||
|
||||
|
||||
async def _stream(monkeypatch, model, source, base_graph=None):
|
||||
|
||||
Reference in New Issue
Block a user