stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.57k stars 1.54k forks source link

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

Closed stefansaasen closed 1 year ago

stefansaasen commented 1 year ago

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: