Skip to content

insert: VALUES accept typegres expressions (parity with SET)#91

Merged
ryanrasti merged 1 commit into
mainfrom
ryan_2_insert_expressions
Jul 23, 2026
Merged

insert: VALUES accept typegres expressions (parity with SET)#91
ryanrasti merged 1 commit into
mainfrom
ryan_2_insert_expressions

Conversation

@ryanrasti

Copy link
Copy Markdown
Owner

InsertRow widens each column to TsTypeOf | StripRequired (same shape as SetRow), and the compile path embeds an incoming SqlValue via toSql() instead of re-wrapping it as a param. A hydrated column from one row now composes straight into another table's insert — no unwrap-to-primitive step. Covered in insert.test.ts.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR brings INSERT ... VALUES to parity with UPDATE ... SET by allowing insert rows to accept typegres expressions (e.g., hydrated row columns) in addition to JS primitives. This unblocks composing values from hydrated rows directly into subsequent inserts without needing to unwrap to primitives first.

Changes:

  • Widened InsertRow to accept TsTypeOf primitives or same-class typegres expressions (via StripRequired, matching SetRow’s shape).
  • Updated INSERT compilation to embed incoming SqlValue expressions directly via .toSql() instead of attempting to re-wrap them as parameters.
  • Added a regression test proving a hydrated column can flow into another table’s VALUES.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/types/runtime.ts Widens InsertRow value types to allow same-class typegres expressions (matching SetRow).
src/builder/insert.ts Inserts now inline SqlValue inputs via toSql() rather than passing them through from(...).
src/builder/insert.test.ts Adds coverage for inserting with hydrated-column expressions in VALUES.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ryanrasti
ryanrasti force-pushed the ryan_1_capnweb_shim branch from 3940059 to 8515194 Compare July 23, 2026 00:12
@ryanrasti
ryanrasti force-pushed the ryan_2_insert_expressions branch from 39617e4 to 6a3ae9a Compare July 23, 2026 00:13
@ryanrasti
ryanrasti changed the base branch from ryan_1_capnweb_shim to main July 23, 2026 00:16
InsertRow widens each column to `TsTypeOf | StripRequired` (same shape
as SetRow), and the compile path embeds an incoming SqlValue via
toSql() instead of re-wrapping it as a param. A hydrated column from
one row now composes straight into another table's insert — no
unwrap-to-primitive step. Covered in insert.test.ts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ryanrasti
ryanrasti force-pushed the ryan_2_insert_expressions branch from 6a3ae9a to 3a5a8d4 Compare July 23, 2026 00:17
@ryanrasti
ryanrasti merged commit 76d2cd8 into main Jul 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants