This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
Connection::getLastGeneratedValue should throw exception when unable to get an Id #343
Open
2 tasks done
When trying to get and Id for a record by using the
Connection::getLastGeneratedValue
method you would expect that an exception is thrown when trying to do something that is not possible or when the database fails to return an ID because this is an exceptional situation.But at this moment the method returns
null
when you use it incorrectly orfalse
when getting the ID from the database fails combined with PHP type system this can cause new errors that are hard to trace.Code to reproduce the issue
Example combined with PostgreSQL database.
Expected results
At this moment the method is not defensive enough and it is easy to make mistakes with it. I would expect it to throw an exception that will explain what is going wrong. It's possible that an migration goes wrong and a sequence is not created causing this code to always return
false
what can be a valid value.The text was updated successfully, but these errors were encountered: