Open
Description
In SQLite3, we can use rowid
pseudo-column and last_insert_rowid()
function to query the last inserted record.
To build such a query with HRR, I tried
lastInsertRecord :: Table r -> Pi r v -> Relation () v
lastInsertRecord tab selector = relation $ do
record <- query $ table tab
let rowid = unsafeProjectSql "rowid"
last_rowid = unsafeProjectSql "last_insert_rowid()"
wheres $ rowid .=. last_rowid
return (record ! selector)
This gives me a Relation
like:
>>> lastInsertRecord tableOfSample id'
SELECT ALL T0.sample_id AS f0, T0.val AS f1 FROM MAIN.sample T0 WHERE (rowid = last_insert_rowid())
This works. However, because rowid
is a pseudo-column of sample
table, it should be T0.rowid
in the above query.
So, is there any way to specify rowid
as a pseudo-column of a table?
Metadata
Metadata
Assignees
Labels
No labels