Repository navigation
Add insertInto(...).values(...) for ClickHouse and Postgres - #9
Merged
Merged
Conversation
INSERT ... VALUES built from the same table definitions queries read. The row type requires every column that is not nullable and has no default; TableOptions.defaults lists defaulted columns, and defineTable derives them and marks MATERIALIZED / ALIAS columns as not insertable. Values are encoded through each column's codec: inlined as literals on ClickHouse, bound as $n on Postgres. Columns are written in table order, and a key some rows omit becomes DEFAULT, which both ClickHouse matrix servers accept. Tenant scope is derived as for queries. compile and Database.run accept an insert. CompiledQuery.kind tells run to send an insert through command and return no rows. Postgres declares ParamStyle.maxParameters (65535); a statement over it fails to compile. Plan for the remaining write phases in design/writes.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (23)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of the write builders planned in
design/writes.md: INSERT ... VALUES from the same table definitions queries read.What changes
nullonly type-checks on nullable columns. A value can be a plain value, aparam.*, or any expression of the column's type.TableOptions.defaults.defineTableworks defaults out fromdefault/defaultExprand recordsMATERIALIZED/ALIAScolumns as not insertable (a type error, and a compile error at runtime).$non Postgres. Columns are written in table order whatever the key order; a key some rows omit becomesDEFAULT(checked on ClickHouse 26.2 and 26.8).ParamStyle.maxParameters; Postgres sets 65535 and a statement over it fails to compile instead of being split.compile/compileUnsafeare overloaded for inserts, andDatabase.runaccepts one. NewCompiledQuery.kind("select"/"insert") letsrunsend an insert throughcommand(needed on ClickHouse) and return[].Not in this PR
RETURNING,ON CONFLICT,INSERT ... SELECTand ClickHouseSETTINGSare phases 2–4 ofdesign/writes.md.Testing
bun run typecheckandbun run test: 493 unit tests and the doc checks pass.src/ch/insert.test.ts; type tests insrc/ch/insert.test-d.ts.DEFAULT, and rollback inside a transaction.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.