postgres.py
postgres.py copied to clipboard
Casting of table rows
When no Model
subclass has been registered for a table, a row from that table contained in a query result isn't parsed at all, it's returned as a string. It would be nicer if the nested row was cast to the same type as the top-level row.
Current behavior:
>>> db.run("CREATE TABLE foo (bar int, baz text)")
>>> db.run("INSERT INTO foo VALUES (1, 'one')")
>>> db.one("SELECT true AS x, (SELECT foo FROM foo) AS foo", back_as='Row')
Row(x=True, foo='(1,foo)')
Desired behavior:
>>> db.one("SELECT true AS x, (SELECT foo FROM foo) AS foo", back_as='Row')
Row(x=True, foo=Row(bar=1, baz='foo'))