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
CREATETABLEIF NOT EXISTS "demo_default" (
"id"CHAR(36) NOT NULL,
"home_path"VARCHAR(255) DEFAULT /dashboard NOT NULL, -- ← unquoted, syntax error"tags"VARCHAR(1000) DEFAULT ["all"] NOT NULL, -- ← unquoted, syntax error"name"VARCHAR(100) DEFAULT "我的团队"NOT NULL, -- ← unquoted, syntax error"method"VARCHAR(32) DEFAULT POST NOT NULL, -- ← treated as column ref"created_at"TIMESTAMPNOT NULL,
PRIMARY KEY("id")
);
Error (PostgreSQL):
ERROR: syntax error at or near "/"
LINE 1: ... VARCHAR(255) DEFAULT /dashboard NOT NULL...
Root Cause
V ORM's default: attribute renders the V expression value directly into SQL without SQL string escaping:
default: '/dashboard' → DEFAULT /dashboard (missing quotes around string)
default: 'POST' → DEFAULT POST (treated as column reference in PG)
default: 0 → DEFAULT 0 (works because numbers don't need quoting)
The default: value is a V expression (V string literal '/dashboard'), but it needs to be rendered as a SQL literal ('/dashboard' with quotes) in the DDL.
Expected Behavior
V string defaults should be properly quoted in generated SQL:
Minimal Reproduction
Model (
model.v):Init (
main.v):Generated DDL (from
-d trace_orm):Error (PostgreSQL):
Root Cause
V ORM's
default:attribute renders the V expression value directly into SQL without SQL string escaping:default: '/dashboard'→DEFAULT /dashboard(missing quotes around string)default: 'POST'→DEFAULT POST(treated as column reference in PG)default: 0→DEFAULT 0(works because numbers don't need quoting)The
default:value is a V expression (V string literal'/dashboard'), but it needs to be rendered as a SQL literal ('/dashboard'with quotes) in the DDL.Expected Behavior
V string defaults should be properly quoted in generated SQL:
Or alternatively, support
default: sql('/dashboard')for raw SQL expressions.Workaround
Move the default into
sql_type:This works because
sql_typeis rendered as raw SQL — but it's fragile and mixes type definition with default value.Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.