nette / database

💾 A database layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.
https://doc.nette.org/database
Other
512 stars 108 forks source link

Fixed Selection::insert spoiling PDO:lastInsertId #217

Closed Stopka closed 5 years ago

Stopka commented 5 years ago

Changes the order of method calls in Selection::insert, so that getPrimarySequence and getPrimaryAutoincrementKey methods are called before actual query. Without this edit calling of these methods can spoil PDO:lastInsertId by database query for building Structure cache, which results in not obtaining new inserted ActiveRow. This fail usualy happened on first insert query when used with StaticConvetions.

dg commented 5 years ago

Great. Can you add a test?

Stopka commented 5 years ago

Ok, I added test covering this bug.

dg commented 5 years ago

Thanks!