File tree Expand file tree Collapse file tree 3 files changed +126
-0
lines changed
Expand file tree Collapse file tree 3 files changed +126
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,7 @@ pub struct RangeVar {
196196 /// the relation/sequence name
197197 pub relname : String ,
198198 /// expand rel by inheritance? recursively act on children?
199+ #[ serde( default ) ]
199200 pub inh : bool ,
200201 /// see RELPERSISTENCE_* in pg_class.h
201202 pub relpersistence : String ,
Original file line number Diff line number Diff line change @@ -1219,6 +1219,22 @@ DROP SUBSCRIPTION mysub;
12191219 assert_debug_snapshot ! ( res) ;
12201220 }
12211221
1222+ #[ test]
1223+ fn parse_inh ( ) {
1224+ let sql = r#"
1225+ ALTER TABLE ONLY public.tasks
1226+ DROP CONSTRAINT tasks_fk,
1227+ ADD CONSTRAINT tasks_fk
1228+ FOREIGN KEY (job_id) REFERENCES public.jobs(external_id)
1229+ ON DELETE CASCADE NOT VALID;
1230+
1231+ ALTER TABLE public.tasks VALIDATE CONSTRAINT tasks_fk;
1232+ "# ;
1233+ let res = parse_sql_query ( sql) ;
1234+ assert ! ( res. is_ok( ) ) ;
1235+ assert_debug_snapshot ! ( res) ;
1236+ }
1237+
12221238 #[ test]
12231239 fn test_parse_create_table_regression ( ) {
12241240 let sql = r#"
Original file line number Diff line number Diff line change 1+ -- -
2+ source : parser / src / parse .rs
3+ expression : res
4+ -- -
5+ Ok (
6+ [
7+ RawStmt (
8+ RawStmt {
9+ stmt: AlterTableStmt (
10+ AlterTableStmt {
11+ cmds: [
12+ AlterTableCmd (
13+ AlterTableCmd {
14+ subtype: DropConstraint ,
15+ name: Some (
16+ " tasks_fk" ,
17+ ),
18+ def: None ,
19+ behavior: Restrict ,
20+ missing_ok: false ,
21+ },
22+ ),
23+ AlterTableCmd (
24+ AlterTableCmd {
25+ subtype: AddConstraint ,
26+ name: None ,
27+ def: Some (
28+ Constraint (
29+ Constraint {
30+ contype: Foreign ,
31+ location: 69 ,
32+ raw_expr: None ,
33+ keys: None ,
34+ indexname: None ,
35+ skip_validation: true ,
36+ initially_valid: false ,
37+ },
38+ ),
39+ ),
40+ behavior: Restrict ,
41+ missing_ok: false ,
42+ },
43+ ),
44+ ],
45+ relation: RangeVar (
46+ RangeVar {
47+ catalogname: None ,
48+ schemaname: Some (
49+ " public" ,
50+ ),
51+ relname: " tasks" ,
52+ inh: false ,
53+ relpersistence: " p" ,
54+ alias: None ,
55+ location: 18 ,
56+ },
57+ ),
58+ relkind: Table ,
59+ missing_ok: false ,
60+ },
61+ ),
62+ stmt_location: 0 ,
63+ stmt_len: Some (
64+ 193 ,
65+ ),
66+ },
67+ ),
68+ RawStmt (
69+ RawStmt {
70+ stmt: AlterTableStmt (
71+ AlterTableStmt {
72+ cmds: [
73+ AlterTableCmd (
74+ AlterTableCmd {
75+ subtype: ValidateConstraint ,
76+ name: Some (
77+ " tasks_fk" ,
78+ ),
79+ def: None ,
80+ behavior: Restrict ,
81+ missing_ok: false ,
82+ },
83+ ),
84+ ],
85+ relation: RangeVar (
86+ RangeVar {
87+ catalogname: None ,
88+ schemaname: Some (
89+ " public" ,
90+ ),
91+ relname: " tasks" ,
92+ inh: true ,
93+ relpersistence: " p" ,
94+ alias: None ,
95+ location: 208 ,
96+ },
97+ ),
98+ relkind: Table ,
99+ missing_ok: false ,
100+ },
101+ ),
102+ stmt_location: 194 ,
103+ stmt_len: Some (
104+ 55 ,
105+ ),
106+ },
107+ ),
108+ ],
109+ )
You can’t perform that action at this time.
0 commit comments