Fixed pgsql lastInserteId#145
Fixed pgsql lastInserteId#145lulco wants to merge 4 commits intonette:masterfrom lulco:pgsql_last_insert_id
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.
the string should be in single quotes, i.e. $primaryKey === '0'
|
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.