-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for foreign key actions (#73)
- Loading branch information
Showing
17 changed files
with
520 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
testdata/input/ddl/alter_table_add_constraint_foreign_key_on_delete_cascade.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2key1, t2key2) on delete cascade |
1 change: 1 addition & 0 deletions
1
testdata/input/ddl/alter_table_add_constraint_foreign_key_on_delete_no_action.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2key1, t2key2) on delete no action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_cascade.sql.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- alter_table_add_constraint_foreign_key_on_delete_cascade.sql | ||
alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2key1, t2key2) on delete cascade | ||
|
||
--- AST | ||
&ast.AlterTable{ | ||
Alter: 0, | ||
Name: &ast.Ident{ | ||
NamePos: 12, | ||
NameEnd: 15, | ||
Name: "foo", | ||
}, | ||
TableAlternation: &ast.AddTableConstraint{ | ||
Add: 16, | ||
TableConstraint: &ast.TableConstraint{ | ||
ConstraintPos: 20, | ||
Name: &ast.Ident{ | ||
NamePos: 31, | ||
NameEnd: 37, | ||
Name: "fkname", | ||
}, | ||
Constraint: &ast.ForeignKey{ | ||
Foreign: 38, | ||
Rparen: 91, | ||
OnDeleteEnd: 109, | ||
Columns: []*ast.Ident{ | ||
&ast.Ident{ | ||
NamePos: 51, | ||
NameEnd: 54, | ||
Name: "foo", | ||
}, | ||
&ast.Ident{ | ||
NamePos: 56, | ||
NameEnd: 59, | ||
Name: "bar", | ||
}, | ||
}, | ||
ReferenceTable: &ast.Ident{ | ||
NamePos: 72, | ||
NameEnd: 74, | ||
Name: "t2", | ||
}, | ||
ReferenceColumns: []*ast.Ident{ | ||
&ast.Ident{ | ||
NamePos: 76, | ||
NameEnd: 82, | ||
Name: "t2key1", | ||
}, | ||
&ast.Ident{ | ||
NamePos: 84, | ||
NameEnd: 90, | ||
Name: "t2key2", | ||
}, | ||
}, | ||
OnDelete: "ON DELETE CASCADE", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
--- SQL | ||
ALTER TABLE foo ADD CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2) ON DELETE CASCADE |
61 changes: 61 additions & 0 deletions
61
testdata/result/ddl/alter_table_add_constraint_foreign_key_on_delete_no_action.sql.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- alter_table_add_constraint_foreign_key_on_delete_no_action.sql | ||
alter table foo add constraint fkname foreign key (foo, bar) references t2 (t2key1, t2key2) on delete no action | ||
|
||
--- AST | ||
&ast.AlterTable{ | ||
Alter: 0, | ||
Name: &ast.Ident{ | ||
NamePos: 12, | ||
NameEnd: 15, | ||
Name: "foo", | ||
}, | ||
TableAlternation: &ast.AddTableConstraint{ | ||
Add: 16, | ||
TableConstraint: &ast.TableConstraint{ | ||
ConstraintPos: 20, | ||
Name: &ast.Ident{ | ||
NamePos: 31, | ||
NameEnd: 37, | ||
Name: "fkname", | ||
}, | ||
Constraint: &ast.ForeignKey{ | ||
Foreign: 38, | ||
Rparen: 91, | ||
OnDeleteEnd: 111, | ||
Columns: []*ast.Ident{ | ||
&ast.Ident{ | ||
NamePos: 51, | ||
NameEnd: 54, | ||
Name: "foo", | ||
}, | ||
&ast.Ident{ | ||
NamePos: 56, | ||
NameEnd: 59, | ||
Name: "bar", | ||
}, | ||
}, | ||
ReferenceTable: &ast.Ident{ | ||
NamePos: 72, | ||
NameEnd: 74, | ||
Name: "t2", | ||
}, | ||
ReferenceColumns: []*ast.Ident{ | ||
&ast.Ident{ | ||
NamePos: 76, | ||
NameEnd: 82, | ||
Name: "t2key1", | ||
}, | ||
&ast.Ident{ | ||
NamePos: 84, | ||
NameEnd: 90, | ||
Name: "t2key2", | ||
}, | ||
}, | ||
OnDelete: "ON DELETE NO ACTION", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
--- SQL | ||
ALTER TABLE foo ADD CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2) ON DELETE NO ACTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.