You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: PostgreSQL: describeReferences() gives the wrong column pairs for a composite foreign key #17680
Describe the bug
On PostgreSQL, describeReferences() gives the wrong columns for a foreign key with two or more columns. Each column of the key is paired with each referenced column, so a key with two columns gives four columns. A key with one column is correct. MySQL and MariaDB are correct.
Cause Phalcon\Db\Dialect\Postgresql::describeReferences() joins key_column_usage and constraint_column_usage only on the constraint name. constraint_column_usage does not give the position of the columns. The query must pair the columns by position, with one of these methods: - Join key_column_usage through referential_constraints to the referenced unique constraint, with position_in_unique_constraint = ordinal_position.
Read pg_constraint and use unnest(conkey, confkey) WITH ORDINALITY.
Details
Phalcon: cphalcon [5.x.x] and phalcon/phalcon [x.x.x] (the same bug is in both)
Activity
niden commentedon Oct 17, 2026
Resolved in #17681