robregonm / YiiFirebird

Firebird Adapter for Yii 1.1.x
13 stars 8 forks source link

findColumns() does not handle composite primary keys #15

Closed mlorentz75 closed 11 years ago

mlorentz75 commented 11 years ago

findColumns() currently does not handle composite primary keys. The SQL for the primary keys seems okay, but the code afterwards does not handle more than one primary key column. Hope to upload a patch real soon myself, as this is currently a showstopper for my project.

robregonm commented 11 years ago

Since I and perhaps many others didn't need composite keys that requirement was not a priority, but your patch will be a very good and useful contribution. Thanks in advance.

edgardmessias commented 11 years ago

See: SELECT RDB$RELATION_CONSTRAINTS.RDB$RELATION_NAME AS TABELA, RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_NAME AS CHAVE, RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME AS INDICE_DA_CHAVE, RDB$INDEX_SEGMENTS.RDB$FIELD_NAME AS CAMPO, RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION AS POSICAO FROM RDB$RELATION_CONSTRAINTS, RDB$INDICES, RDB$INDEX_SEGMENTS WHERE RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' AND RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME = RDB$INDICES.RDB$INDEX_NAME AND RDB$INDEX_SEGMENTS.RDB$INDEX_NAME = RDB$INDICES.RDB$INDEX_NAME ORDER BY RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_NAME, RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION ;

mlorentz75 commented 11 years ago

@edgardmessias Thanks. The query in findColumns() already provided the necessary information. It was just that only the first primary key got evaluated.