feat(query): column-list INSERT and column DEFAULT#30
Merged
Conversation
INSERT now accepts an explicit column list (`INSERT INTO t (a, c) ...`) and short positional rows; columns not supplied fall back to their DEFAULT, then NULL if nullable, else error. A column's DEFAULT is bound at CREATE TABLE and stored on the field as a JSON-serialized expression, so the storage layer stays free of any query-layer type. At INSERT the default is deserialized and evaluated per row (so a future volatile default like now()/uuid_v4() generates a fresh value each row). Defaults are constant expressions — the binder rejects column references (no scope) and subqueries, matching Postgres. Covered by default.slt (typed-literal, expression, and UUID defaults; column-list mapping; per-row fill; rejected cases). Drops two ddl.rs tests whose behavior the feature intentionally changes.
Per the "spec tests for anything SQL-shaped" mandate, migrate the exec-SQL-and-assert tests out of tests/ddl.rs into .slt specs driven through the real server: - ddl/schema.slt: CREATE SCHEMA create/use, default-project shorthand, IF NOT EXISTS idempotency, rejected forms, CREATE TABLE error paths, OR REPLACE on a missing table. - insert.slt: NULL into NOT NULL / nullable, narrowing range check. tests/ddl.rs keeps only what spec can't express: catalog seeding, schema field/nullable introspection, OR REPLACE schema-swap internals, and the stored integer-width assertion after coercion (23 tests -> 4). Existing round-trip/filter/type-mismatch/duplicate cases were already covered by ddl/create_replace.slt and smoke.slt.
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.
DEFAULT + column-list INSERT
INSERT INTO t (a, c) ...) and short positional rows; columns not supplied fall back to theirDEFAULT, thenNULLif nullable, else error.DEFAULTis bound at CREATE TABLE and stored on the field as a JSON-serialized expression, so the storage layer stays free of any query-layer type. At INSERT it's deserialized and evaluated per row (so a future volatile default likenow()/uuid_v4()generates a fresh value each row).Test migration (spec-tests-over-Rust mandate)
tests/ddl.rs(23 → 4) into specs driven through the real server:ddl/schema.slt,insert.slt.tests/ddl.rskeeps only what spec can't express (catalog seeding, schema field/nullable introspection, OR REPLACE internals, stored integer-width assertion).planner.rs(plan shape),volcano.rs(direct plans),sql/mod.rs(parser API) correctly stay in Rust.Coverage
default.sltcovers typed-literal (UUID/DATE/TIME/NUMERIC/BOOLEAN/INTERVAL), expression (CAST/::/COALESCE/CASE/GREATEST), and UUID defaults; column-list mapping; per-row fill across multi-row inserts; rejected cases. clippy-D warnings+ fmt clean; full workspace + 14 spec files green.🤖 Generated with Claude Code