★ wanayoo — archive 1999 https://github.com/JSQLParser/JSqlParser/issues/958Nouvelle recherche | Portail wanayoo
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

JSqlParser v3.0 doesn't support some foreign key reference option #958

Closed
FoxInNorth opened this issue Mar 10, 2020 · 2 comments
Closed

JSqlParser v3.0 doesn't support some foreign key reference option #958

FoxInNorth opened this issue Mar 10, 2020 · 2 comments

Comments

@FoxInNorth
Copy link

@FoxInNorth FoxInNorth commented Mar 10, 2020

Describe the bug
JSqlParser v3.0 doesn't support some foreign key reference option, include RESTRICT, SET NULL, SET DEFAULT.

Reference:

[CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (col_name, ...)
REFERENCES tbl_name (col_name,...)
[ON DELETE reference_option]
[ON UPDATE reference_option]

reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT

https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html#foreign-key-referential-actions

To Reproduce
When use JSqlParser parse below creation table SQL for table: foreign_key_reference_option_sample, there was exception:

create table foreign_key_reference_option_sample
(
id int primary key,
country_id int not null,
state_id int not null,
city_id int null,
person_id int not null,
career_id int not null,
key countryKey(country_id),
key stateKey(state_id),
key cityKey(city_id),
key personKey(person_id),
key careerKey(career_id),
CONSTRAINT fk_a FOREIGN KEY (country_id) REFERENCES t1 (country) ON UPDATE RESTRICT,
CONSTRAINT fk_b FOREIGN KEY (state_id) REFERENCES t1 (state) ON UPDATE CASCADE,
CONSTRAINT fk_c FOREIGN KEY (city_id) REFERENCES t1 (city) ON UPDATE SET NULL,
CONSTRAINT fk_d FOREIGN KEY (person_id) REFERENCES t1 (person) ON UPDATE NO ACTION,
CONSTRAINT fk_e FOREIGN KEY (country_id) REFERENCES t1 (country) ON DELETE RESTRICT,
CONSTRAINT fk_f FOREIGN KEY (state_id) REFERENCES t1 (state) ON DELETE CASCADE,
CONSTRAINT fk_g FOREIGN KEY (city_id) REFERENCES t1 (city) ON DELETE SET NULL,
CONSTRAINT fk_h FOREIGN KEY (person_id) REFERENCES t1 (person) ON DELETE NO ACTION
);

create table t1 (
id int primary key,
city int null,
country int not null,
state int not null,
person int not null,
career int not null,
key cityindex (city),
key countryindex (country),
key stateindex (state),
key personindex (person),
key careerindex (career)
);

Expected behavior
JSqlParser need to parse the table# foreign_key_reference_option_sample creation SQL successfully.

System

  • Database you are using: MySQL 8.0
  • Java Version: java 8
  • JSqlParser version: 3.0
@gitmotte
Copy link
Contributor

@gitmotte gitmotte commented Jul 29, 2020

duplicate #985

@wumpz
Copy link
Member

@wumpz wumpz commented Jul 29, 2020

Thx so I will close this one.

@wumpz wumpz closed this Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.