Closed jmichelf closed 3 years ago
Thanks for reporting. This should be fixed in https://github.com/bcosca/fatfree-core/commit/28e7e759c9906bcbbed93d909559356eaec6b7da. I assumed that the PK always appears first in the list.
If that was not the case, we should add an ORDER BY
condition in the SQL statement. Something like ORDER BY C.ordinal_position,CASE WHEN T.CONSTRAINT_TYPE='PRIMARY KEY' THEN 1 END
. But this would have to be tested against the other engines mssql|sqlsrv|sybase|dblib|pgsql|odbc
.
Hi. Thanks, this fix solved my problem. Jean-Michel
@xfra35 this does not work with MSSQL using the dblib driver. The primary column does not appear first in the list thus the sql.php is unable to determine which is the primary column.
Hi For me, the function schema($table,$fields=NULL,$ttl=0) in sql.php wrongly gives 'pkey'=false when using it with PostgreSQL on a table that have both PK and FK constraints on the same column. In same condition with MySQL, it gives correct result. The reason might be that the query used for 'pgsql' returns a duplicate row for the same field. Here after the illustration on 'pgsql' :
The corresponding query on 'mysql':
Additionally, the 'pgsql' column 'id' has no default value, which is intended in my case, and probably has no impact here.
Thanks for your great work on 'f3'. Kind regards Jean-Michel