-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assumption of PostgreSQL Primary Key Sequence name is incorrect #1069
Comments
Hi @fukawi2 |
Yes, that works perfectly in my testing. Thanks! :) |
This change (or "fix") has introduced a new, VERY serious problem, which didn't exist when using sequences. Now it is NOT possible to insert into a view (which in turn uses a trigger for update of multiple tables related to the view), because the $aik is empty. This produces a 500 error.
Therefore this change is indeed very contra-productive. |
fixed in the latest commit. |
@ikkez Thank you. |
See issue #124. Also present here: https://github.com/bcosca/fatfree/blob/master/lib/db/sql/mapper.php#L433
Issue #124 states:
This assumption is not safe. In my case, I have an inherited table
msgs_master
which is inherited intomsgs_current
andmsgs_archive
. New rows are inserted tomsgs_current
, while a maintenance script moves rows older than a given time frame tomsgs_archive
. The primary key for all columns is calledmid
Because
msgs_current
andmsgs_archive
inherit their columns frommsgs_master
, the sequence is calledmsgs_master_mid_seq
for all 3 tables. The above referenced code presumes the sequence includes the name of the table you're inserting to, but when inserting tomsgs_current
the sequencemsgs_master_mid_seq
will be used.IMPACT
This breaks the save() function because when it tries to reload the record, it cannot determine the correct value for
mid
for the select.Perhaps the RETURNING feature of PostgreSQL INSERT could be used somehow:
This functionality was introduced in PG 8.2, which means it is in all supported versions of PostgreSQL.
The text was updated successfully, but these errors were encountered: