-
Notifications
You must be signed in to change notification settings - Fork 23
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
Wrong parameter in AbstractTable::insertRowPerform() for lastInsertId method at PostgreSQL #71
Comments
To make sure I understand: are you saying you need a sequence name other than the autoincrement column? |
Right, the name of a sequence. (http://php.net/manual/en/pdo.lastinsertid.php#refsect1-pdo.lastinsertid-description) My current workaround in the mapper: if ($record->getRow()->getStatus() === Row::INSERTED) {
/** @var \Aura\Sql\ExtendedPdoInterface $connection */
$connection = $this->getTable()->getWriteConnection();
$lastId = $connection->lastInsertId('foobar_id_seq');
} (Thanks for the quick response!) |
I could have sworn I had something like that workaround implemented in the Insert object(s) for Postgres. Let me take a look around. Sorry for the hassle. |
Turns out what I have is in Aura.SqlQuery, and it's for extended Postgres tables, not non-extended ones. Working on a fix now. Thanks for your patience. |
Update: I did implement it in Aura.SqlQuery: https://github.com/auraphp/Aura.SqlQuery/blob/3.x/src/Pgsql/Insert.php#L47-L54 But Atlas doesn't call getLastInsertIdName, it just presumes the name is the column name. Continuing to work on it. |
@froschdesign Do me a favor? In your local copy of
To this:
And tell me if it works for you. |
@froschdesign see also #72 as a fix |
@pmjones
Works like a charm! 👍 |
Excellent! I have applied the fix on the 1.x branch; use that, until the next release comes out (which I hope to do later today). |
Great! Thank you. |
At a PostgreSQL database the name of a sequence object is required for
PDO::lastInsertId
. At the moment the name of the autoincrement column is used.Atlas.Orm/src/Table/AbstractTable.php
Lines 363 to 366 in bf4d2de
Changing the
getAutoinc
method in the specific table class doesn't work, because the methodAbstractTable::insertRowPrepare()
needs the name of the autoincrement column.Atlas.Orm/src/Table/AbstractTable.php
Lines 329 to 332 in bf4d2de
The text was updated successfully, but these errors were encountered: