Skip to content

Commit 0e93ac3

Browse files
authored
Add issue 147 file parsing regression test (#334)
1 parent 800f96f commit 0e93ac3

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
## Tests
2020
- If changes affect behavior, run targeted tests when practical.
21+
- Before reporting results, always run tests via `tox`; all tests must be green.
2122
- Report test commands and results; do not fabricate.
2223
- Always run linters before committing (ruff and black).
2324

tests/test_read_from_file.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,49 @@ def test_parse_from_file_issue_148_mediawiki_comments_and_mysql_indexes(tmp_path
445445
assert result[0]["columns"][1]["unique"] is True
446446
assert result[0]["index"][0]["columns"] == ["cat_pages"]
447447
assert result[0]["index"][1]["detailed_columns"][0]["length"] == 32
448+
449+
450+
def test_parse_from_file_issue_147_inline_foreign_key_on_delete_set_null(tmp_path):
451+
ddl_file = tmp_path / "issue_147_comtccmmncode.sql"
452+
ddl_file.write_text(
453+
"""
454+
CREATE TABLE COMTCCMMNCLCODE
455+
(
456+
CL_CODE CHAR(3) NOT NULL,
457+
CL_CODE_NM VARCHAR2(60) NULL,
458+
CONSTRAINT COMTCCMMNCLCODE_PK PRIMARY KEY (CL_CODE)
459+
);
460+
461+
CREATE TABLE COMTCCMMNCODE
462+
(
463+
CODE_ID VARCHAR2(6) NOT NULL,
464+
CODE_ID_NM VARCHAR2(60) NULL,
465+
CODE_ID_DC VARCHAR2(200) NULL,
466+
USE_AT CHAR(1) NULL,
467+
CL_CODE CHAR(3) NULL,
468+
FRST_REGIST_PNTTM DATE NULL,
469+
FRST_REGISTER_ID VARCHAR2(20) NULL,
470+
LAST_UPDT_PNTTM DATE NULL,
471+
LAST_UPDUSR_ID VARCHAR2(20) NULL,
472+
CONSTRAINT COMTCCMMNCODE_PK PRIMARY KEY (CODE_ID),
473+
CONSTRAINT COMTCCMMNCODE_FK1 FOREIGN KEY (CL_CODE)
474+
REFERENCES COMTCCMMNCLCODE(CL_CODE) ON DELETE SET NULL
475+
);
476+
""",
477+
encoding="utf-8",
478+
)
479+
480+
result = parse_from_file(str(ddl_file), parser_settings={"silent": False})
481+
482+
assert len(result) == 2
483+
assert result[1]["table_name"] == "COMTCCMMNCODE"
484+
assert result[1]["columns"][4]["name"] == "CL_CODE"
485+
assert result[1]["columns"][4]["references"] == {
486+
"table": "COMTCCMMNCLCODE",
487+
"schema": None,
488+
"on_delete": "SET NULL",
489+
"on_update": None,
490+
"deferrable_initially": None,
491+
"constraint_name": "COMTCCMMNCODE_FK1",
492+
"column": "CL_CODE",
493+
}

0 commit comments

Comments
 (0)