dg / dibi

Dibi - smart database abstraction layer
https://dibiphp.com
Other
487 stars 136 forks source link

getInsertId() in PostgreSQL driver #270

Closed ghost closed 6 years ago

ghost commented 6 years ago

Description

Current development version in repository has an problem with returning insert Id in PostgreSQL database driver - method getInsertId(). Expected is integer, but in $row[0] is returned string which should be casted as integer (return is_array($row) ? (int)$row[0] : null;). That causes TypeError (Return value of Dibi\Drivers\PostgreDriver::getInsertId() must be of the type integer or null, string returned)

But, here is also another problem. PostgreSQL for example support bigint format which values could be much higher than integer's max value. Would be good to keep support even for this high values - in this case use strict output format to integer does not make sense.

seancsnyder commented 6 years ago

I've also encountered this bug :-(

Seems like a very straight forward fix, and I wouldn't mind opening up a pull request...unless someone is already working on this issue.

dg commented 6 years ago

@vinylio-cz PHP int has the same limitations as Postgres BIGINT.

ghost commented 6 years ago

@dg: This issue is about something different than size of BIGINT, however this issues was fixed in commit from 21.12.2017 - https://github.com/dg/dibi/commit/5046929e28426a74c6c60c03d0562f5c306d474d#diff-3c86f559eedd2e9211d8b6dc5279255e

Thanks !