Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #20 column_constraint REFERENCES for accepting empty column list #35

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/antlr/TSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,7 @@ column_constraint
:(CONSTRAINT constraint=id)?
((PRIMARY KEY | UNIQUE) clustered? with_index_options?
| CHECK for_replication? LR_BRACKET search_condition RR_BRACKET
| (FOREIGN KEY)? REFERENCES table_name LR_BRACKET pk = column_name_list RR_BRACKET (on_update | on_delete)*
| (FOREIGN KEY)? REFERENCES table_name (LR_BRACKET pk = column_name_list RR_BRACKET)? (on_update | on_delete)*
| DEFAULT expression
| null_notnull
| WITH VALUES
Expand Down
49 changes: 49 additions & 0 deletions test/JDBC/expected/BABEL-COLUMN-CONSTRAINT.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
USE master;
GO

CREATE SCHEMA [Babelfish_COLCONST];
GO

create table [Babelfish_COLCONST].[a] (
id int identity primary key,
texto varchar(50) NOT NULL
);
GO

create table [Babelfish_COLCONST].[b] (
id int identity primary key,
foreign_id int not null references [Babelfish_COLCONST].[a],
texto varchar(50) NOT NULL
);
GO

create table [Babelfish_COLCONST].[c] (
id int identity primary key,
foreign_id int not null,
foreign key(foreign_id) references [Babelfish_COLCONST].[a](id),
texto varchar(50) NOT NULL
);
GO

SET IDENTITY_INSERT [Babelfish_COLCONST].[a] ON;
insert into [Babelfish_COLCONST].[a](id,texto) values(1, 'some text');
SET IDENTITY_INSERT [Babelfish_COLCONST].[a] OFF;
GO
~~ROW COUNT: 1~~


insert into [Babelfish_COLCONST].[b](foreign_id, texto) values(1,'insert text');
GO
~~ROW COUNT: 1~~


insert into [Babelfish_COLCONST].[c](foreign_id, texto) values(1,'insert text');
GO
~~ROW COUNT: 1~~


DROP TABLE [Babelfish_COLCONST].[c];
DROP TABLE [Babelfish_COLCONST].[b];
DROP TABLE [Babelfish_COLCONST].[a];
DROP SCHEMA [Babelfish_COLCONST];
GO
43 changes: 43 additions & 0 deletions test/JDBC/input/BABEL-COLUMN-CONSTRAINT.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
USE master;
GO

CREATE SCHEMA [Babelfish_COLCONST];
GO

create table [Babelfish_COLCONST].[a] (
id int identity primary key,
texto varchar(50) NOT NULL
);
GO

create table [Babelfish_COLCONST].[b] (
id int identity primary key,
foreign_id int not null references [Babelfish_COLCONST].[a],
texto varchar(50) NOT NULL
);
GO

create table [Babelfish_COLCONST].[c] (
id int identity primary key,
foreign_id int not null,
foreign key(foreign_id) references [Babelfish_COLCONST].[a](id),
texto varchar(50) NOT NULL
);
GO

SET IDENTITY_INSERT [Babelfish_COLCONST].[a] ON;
insert into [Babelfish_COLCONST].[a](id,texto) values(1, 'some text');
SET IDENTITY_INSERT [Babelfish_COLCONST].[a] OFF;
GO

insert into [Babelfish_COLCONST].[b](foreign_id, texto) values(1,'insert text');
GO

insert into [Babelfish_COLCONST].[c](foreign_id, texto) values(1,'insert text');
GO

DROP TABLE [Babelfish_COLCONST].[c];
DROP TABLE [Babelfish_COLCONST].[b];
DROP TABLE [Babelfish_COLCONST].[a];
DROP SCHEMA [Babelfish_COLCONST];
GO