You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Insert with defaults: nextval doesn't handle newtype-wrapped Id #328
So that's a way to reduce rowsvalues to just (name, domain) pairs that I wanted, omitting DEFAULT columns 🤔
Unfortunately, doing this precludes both the IODKU & RETURNING clauses (because last_seen & id columns are no longer "in scope"). Thus if I need them, I must abandon the projection & say clientId = unsafeDefault.
@ocharles do you think it's a good idea to extend the Selects names exprs existential on Insert constructor to also contain a projection allowing to skip defaulted columns in rows Query only?.. I mean, maybe this:
Because conceivably, the common use-case for RETURNING asks to fetch a defaulted column (id, timestamp) immediately as part of a data-writing query... so, that column must be in names and therefore in exprs. However, by allowing exprsNonDefault to be "smaller than" exprs, the API might elegantly allow omitting those nextval and unsafeDefault calls.
Activity
ulidtko commentedon Jun 5, 2024
Ohhh... wow OK, interesting.
TableSchemais a Functor! 💡Which means I can indeed narrow down the existing 4-column schema, by projecting out just the 2 columns of interest:
So that's a way to reduce
rowsvaluesto just(name, domain)pairs that I wanted, omittingDEFAULTcolumns 🤔Unfortunately, doing this precludes both the IODKU & RETURNING clauses (because
last_seen&idcolumns are no longer "in scope"). Thus if I need them, I must abandon the projection & sayclientId = unsafeDefault.@ocharles do you think it's a good idea to extend the
Selects names exprsexistential onInsertconstructor to also contain a projection allowing to skip defaulted columns inrowsQuery only?.. I mean, maybe this:Because conceivably, the common use-case for
RETURNINGasks to fetch a defaulted column (id, timestamp) immediately as part of a data-writing query... so, that column must be innamesand therefore inexprs. However, by allowingexprsNonDefaultto be "smaller than"exprs, the API might elegantly allow omitting thosenextvalandunsafeDefaultcalls.JackKelly-Bellroy commentedon May 7, 2025
Semi-related: #373 might be an answer for
newtype-wrapped ID columns, but I'd want help to convince myself that it's safe.TeofilC commentedon Sep 21, 2026
#418 might solve this