Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Primary keys always get reset using Orm
I just updated all of my company's Fuel libraries to the latest versions using composer. I'm currently using fuel/orm version 22.214.171.124. Long story short, something was changed in the way ORM handles primary keys which impacts any primary key that seems to be anything other than a non auto-incrementing integer.
We have several tables where the primary key of the table is not an integer, and we generate the primary key manually before insertion. We have some legacy tables that use an email address, some tables have a username (string), and some newer tables are using UUIDs. Since the latest Orm update, you can no longer set the primary key manually, and this has broken much of our legacy code. Any primary key that is manually set is now reset by the Orm package.
I have pin-pointed the issue down to line 943 of file packages/orm/classes/model.php. If I comment this line out, my primary keys remain set and my legacy code continues to work normally.
While I get the point of using an auto-incrementing integer for consistency, memory and speed, this prevents the usage of other ID types (mentioned above), especially UUIDs. Is there any specific reason this was put into the latest Orm update, and is there a way to override the type of ID that Fuel expects?
Upgrade your ORM package to 1.9/develop, and set
for all models that require the PK to be set manually, and are being set through forge().
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion