Closed stefansaasen closed 1 year ago
See https://github.com/stephencelis/SQLite.swift/pull/1217 for a possible fix.
cc @NathanFallet
You're right. I didn't see your PR was not marking this issue for auto fix (using "Fix #..." in the PR description)
Good point. I've created another issue and a possible fix and linked them in both directions now.
Given the following
CREATE TABLE
statement:A call to
db.schema.columnDefinitions(table: "t")
should return threeColumnDefinition
s where the column definitions forcol1
andcol2
are marked as being part of the primary key.Instead, only the first column is marked as being part of the primary key.
Example test case (e.g. in
SchemaReaderTests
):The test fails, as the second column is not detected as being part of the composite primary key.
This is due to the following line:
https://github.com/stephencelis/SQLite.swift/blob/f1bee07ea9aa304d7e7024e759c4a031672c8732/Sources/SQLite/Schema/SchemaReader.swift#L28
The
PRAGMA
table_info
that is used to return the column definitions, returns one row for each defined column. Thepk
column contains:See https://www.sqlite.org/pragma.html#pragma_table_info
A possible fix could be to change that line to:
Build Information
0.14.1
14.3
and macOS Ventura13.4