Possible bug in Nette\Database causing Selection::insert() to return FALSE
- thunderbuff
- Member | 164
Hello everyone,
I think I have found (similar) problem mentioned in this question: https://forum.nette.org/…se-nette-2-3
If I call
<?php
$row = $table->insert([/*...*/]);
?>
with my cache freshly deleted it returns FALSE.
I have discovered the problem on this line in Selection class:
https://github.com/…election.php#L726
Selection::getPrimarySequence() is called after INSERT statement and it executes many queries to build a cache. Unfortunately, executing those queries causes PDO::lastInsertId() to return “0” instead of real ID – which prevents from SELECTing inserted row and makes Selection::insert() to return FALSE.
The solution is simple, moving line 726 to the beginning of insert method solves the issue.
This error occurs only with cache freshly cleared.
Is this a bug?
Last edited by thunderbuff (2015-08-05 23:34)