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

SchemaReader: return the correct column definition for a composite primary key #1217

Merged

Conversation

stefansaasen
Copy link
Contributor

The PRAGMA table_info that is used to return the column definitions, returns one row for each defined column. The pk column contains:

... either zero for columns that are not part of the primary key, or the 1-based index of the column within the primary key).

See https://www.sqlite.org/pragma.html#pragma_table_info

Checking whether the pk column equals 1 only detects a single primary key and ignores other columns that are part of a composite primary key.

Thanks for taking the time to submit a pull request.

Before submitting, please do the following:

  • Run make lint to check if there are any format errors (install swiftlint first)
  • Run swift test to see if the tests pass.
  • Write new tests for new functionality.
  • Update documentation comments where applicable.

…imary key

The `PRAGMA` `table_info` that is used to return the column definitions,
returns one row for each defined column. The `pk` column contains:

> ... either zero for columns that are not part of the primary key, or the 1-based index of the column within the primary key).

See https://www.sqlite.org/pragma.html#pragma_table_info

Checking whether the `pk` column equals 1 only detects a single primary
key and ignores other columns that are part of a composite primary key.
Copy link
Collaborator

@nathanfallet nathanfallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@nathanfallet nathanfallet merged commit d34f63a into stephencelis:master Jun 9, 2023
2 checks passed
@stefansaasen stefansaasen deleted the bugfix/composite-primary-keys branch June 9, 2023 11:17
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.

None yet

2 participants