As mentioned in bug 37601 comment #2 and showing up again when testing Gerrit change #27939, when inserting a new row, ORMRow explicitly passes NULL as the value for the ID column which in MySQL means "use next value", but in PostgreSQL means "use NULL". It can be worked around by passing the keyword "DEFAULT" (without quotes) as the value, e. g. "INSERT INTO t (c) VALUES (DEFAULT);".
The easiest solution is to exclude ID columns in ORMRow::getWriteValues() when their value is null, but this prohibits the (not so probable) scenario where you set the id field of a row to null and then call update() to assign it a new id. However, the current code would fail in this case as well as it assumes via getUpdateConditions() that the value of the id field prior to the update is the same as after.
I'll submit a changeset with that understanding later.
Version: 1.21.x
Severity: major
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=37601