mcfunley / pugsql

A HugSQL-inspired database library for Python
https://pugsql.org
Apache License 2.0
673 stars 22 forks source link

Uniform `:insert` return type #7

Closed mcfunley closed 5 years ago

mcfunley commented 5 years ago

https://github.com/mcfunley/pugsql/pull/6 added an :insert return type which uses lastrowid to return the value inserted.

This probably works non-uniformly in postgres, etc, which have INSERT ... RETURNING syntax for accomplishing this.

What might work here is a :scalar type, which returns the first row / first column. (Arguably we need that anyway). Then :insert could fall back to this in cases where lastrowid isn't supported by the dbapi.

mcfunley commented 5 years ago

This is done, :insert falls back to :scalar behavior if lastrowid isn't supported.