chop-dbhi/dataexpress

Code should not assume that keys will be returned

Closed this issue · 1 comments

For various (bad) reasons, the default insert behavior for single rows in DataExpress has been to do an insert and have the driver return the primary key of the just inserted row. This has largely been because the Postgres driver echoes the entire row back when you do this.

This behavior is non-standard. In fact, mySQL will REFUSE to return any results set at all when the key column isn't an auto-generated key. Furthermore, it ONLY returns the key, not the rest of the row.

I am therefore adding an insertReturningKeys method that will do this when you really want it, but it will no longer be the default. There are likely knock-on effects inside the DSL for dealing with insertReturningKeys. In the meantime, I am converting all calls to "insert" into "insertReturningKeys" so as to preserve existing functionality until this can be fully addressed.

This behavior has been fixed in subsequent versions