-
-
Notifications
You must be signed in to change notification settings - Fork 110
Fixed pgsql lastInserteId #145
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
Conversation
|
In PHP 7.0.11 Postgres PDO lastInsertId() was changed: http://php.net/ChangeLog-7.php#7.0.11 #hacktoberfest |
src/Database/Table/Selection.php
Outdated
| : NULL | ||
| ); | ||
| if ($primaryKey === FALSE) { | ||
| if ($primaryKey === FALSE || $primaryKey === "0") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the string should be in single quotes, i.e. $primaryKey === '0'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, fixed
|
What about simple |
|
@dg That's less obvious. I think the current solution is better. Even better (again for clarity) might be to add comment or split the condition based on PHP_VERSION_ID or both, e.g. if ($primaryKey === '0' && (PHP_VERSION_ID < 70011 && $primaryKey === FALSE)) { // php issue #72633 |
|
So? Which alternative will be accepted and merged? I am OK with all of them, just need this fix. |
|
I dont like fix for specific DB in common class. |
|
Well, I just realize that it is not just pgsql problem. This part of code is executed: And returns In this query is the only driver-specific problem with pgsql uuid type, because it throws exception: |
06e5f54 to
44a230d
Compare
|
It seems that it is '' in mssql |
|
This seems to be a wrong fix; personally, I have a db with table with primay value |
|
So '0' can be missing primary and correct primary? I don't know how to differentiate between them. The only solution I can see is to not support primary value '0'. |
|
You can definitely insert '0' into a PK column in MySQL. I'm ok with not-supporting the PK '0', but the unification may be done in PgSQLDriver. |
|
MySQL returns '0' when primary key is missing. It seems that condition in Selection was wrong. |
No description provided.