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

feat: ignore named primary keys with correct name #286

Merged
merged 3 commits into from
Jul 23, 2022

Conversation

olavloite
Copy link
Collaborator

CREATE TABLE statements that contain a named primary key constraint are
rejected by the backend, as the name of a primary key is fixed to 'PK_<table_name>'.
This change parses and removes named primary key constraint from CREATE TABLE
statements when these specify the same name as the generated name. This enables
the usage of frameworks that always generate CREATE TABLE statements with a named
primary key constraint, as long as the name that has been configured is equal to
the fixed name. The fact that the named constraint is stripped from the DDL
statement does not have any effect on the result of the statement, as the
generated name will be equal to the name specified in the statement.

CREATE TABLE statements that contain a named primary key constraint are
rejected by the backend, as the name of a primary key is fixed to 'PK_<table_name>'.
This change parses and removes named primary key constraint from CREATE TABLE
statements when these specify the same name as the generated name. This enables
the usage of frameworks that always generate CREATE TABLE statements with a named
primary key constraint, as long as the name that has been configured is equal to
the fixed name. The fact that the named constraint is stripped from the DDL
statement does not have any effect on the result of the statement, as the
generated name will be equal to the name specified in the statement.
@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #286 (a24b316) into postgresql-dialect (7fc5d51) will increase coverage by 0.08%.
The diff coverage is 94.44%.

@@                   Coverage Diff                    @@
##             postgresql-dialect     #286      +/-   ##
========================================================
+ Coverage                 82.61%   82.69%   +0.08%     
- Complexity                 1306     1315       +9     
========================================================
  Files                       107      107              
  Lines                      4521     4554      +33     
  Branches                    559      568       +9     
========================================================
+ Hits                       3735     3766      +31     
- Misses                      600      601       +1     
- Partials                    186      187       +1     
Flag Coverage Δ
all_tests 82.69% <94.44%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...loud/spanner/pgadapter/statements/DdlExecutor.java 86.57% <93.75%> (+1.83%) ⬆️
...oud/spanner/pgadapter/statements/SimpleParser.java 90.00% <100.00%> (+0.18%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.

@olavloite olavloite marked this pull request as ready for review July 20, 2022 08:39
@olavloite olavloite merged commit 6d90366 into postgresql-dialect Jul 23, 2022
@olavloite olavloite deleted the named-primary-key branch July 23, 2022 13:50
pratickchokhani pushed a commit that referenced this pull request Jul 25, 2022
CREATE TABLE statements that contain a named primary key constraint are
rejected by the backend, as the name of a primary key is fixed to 'PK_<table_name>'.
This change parses and removes named primary key constraint from CREATE TABLE
statements when these specify the same name as the generated name. This enables
the usage of frameworks that always generate CREATE TABLE statements with a named
primary key constraint, as long as the name that has been configured is equal to
the fixed name. The fact that the named constraint is stripped from the DDL
statement does not have any effect on the result of the statement, as the
generated name will be equal to the name specified in the statement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant