From 528d036856da7a0827d7e48215fbda4a4bdbbb52 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 27 Aug 2026 17:37:39 +0000 Subject: [PATCH 1/2] fmt: keep the author's operator, join and parameter spellings; lowercase coalesce MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SQLite gives several constructs more than one spelling, and the formatter was silently picking one: != printed as <> and == as =, a comma-separated FROM item printed as JOIN, a bare JOIN with no ON printed as CROSS JOIN — a planner hint in SQLite the author did not write — and a numbered parameter printed as a bare ?, which is worse than a spelling change: reordered ?N parameters bind by their numbers, so VALUES (?2, ?1) rewritten to (?, ?) swaps its arguments. Operators keep pg_query's shape: A_Expr.Name is the operator as the engine's parser saw it, and since meyer's tree keeps only the operator kind, the sqlite converter reads the author's spelling back out of the source between the operands. The compiler already recognizes every spelling, as it must for MySQL, whose canonical != flows through the same lists. Joins that SQLite treats distinctly become distinct: JoinType gains JoinTypeCross (the planner hint) and JoinTypeComma (its own syntax) beyond the libpg_query set, the sqlite converter maps to them, and the printer spells each as itself — which retires the printer's guess that an inner join with no condition must be a CROSS JOIN. PostgreSQL, whose grammar really does mean CROSS JOIN by that shape (a bare JOIN without ON is a syntax error there), now says so in its converter. Redundant spellings still normalize: INNER JOIN prints as JOIN and LEFT OUTER JOIN as LEFT JOIN, which mean exactly the same thing. Parameters use the numbering the node already records: Dialect.Param gains a numbered flag, ParamRef passes its Dollar field, and sqlite prints ?N for a numbered parameter and ? for a bare one. Compound selects gain the seam boundary the clauses already had: an author who broke the line around UNION, INTERSECT or EXCEPT keeps the operator on its own line, and a one-line compound stays on one line. Statements sqlc has no node for (PRAGMA and friends) stay in the file: ParseFile kept them out of its statement list, so the formatter never saw their extents — it deleted the statements and pulled the name annotations of their neighbours inside the preceding query. They now stay in the list as TODOs, which render as nothing and fall back verbatim; Parse filters them for the compiler, whose skip behavior is unchanged. The file-level belt also refuses any result that changes the file's statement count, so nothing of this class can slip through again. The ON CONFLICT DO UPDATE SET list also gains the boundaries the UPDATE statement's own SET list has: an author who broke the assignments keeps one per line, with the conflict clause's WHERE at clause level, and a one-line upsert stays on one line. COALESCE also drops to lower case: it printed upper-case only because sqlc special-cases it into a dedicated node for nullability inference whose Format hardcoded the spelling, while every other function call prints through FuncCall with its identifier folded lower. The fmt endtoend case pins all of it. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_018MTvpHqNMadH12pTtsgUq2 --- internal/cmd/fmt.go | 8 ++-- internal/compiler/output_columns.go | 2 +- .../endtoend/testdata/fmt/sqlite/query.sql | 40 +++++++++++++++++++ .../endtoend/testdata/fmt/sqlite/stdout.txt | 18 +++++++++ internal/engine/clickhouse/format.go | 2 +- internal/engine/dolphin/format.go | 2 +- internal/engine/postgresql/convert.go | 10 ++++- internal/engine/postgresql/reserved.go | 4 +- internal/engine/sqlite/convert.go | 32 ++++++++++++++- internal/engine/sqlite/format.go | 16 ++++++-- internal/engine/sqlite/parse.go | 32 ++++++++++----- internal/sql/ast/a_expr.go | 9 ++++- internal/sql/ast/coalesce_expr.go | 4 +- internal/sql/ast/join_expr.go | 37 ++++++++--------- internal/sql/ast/join_type.go | 7 ++++ internal/sql/ast/on_conflict_clause.go | 24 ++++++++--- internal/sql/ast/param_ref.go | 2 +- internal/sql/ast/select_stmt.go | 4 ++ internal/sql/format/format.go | 7 +++- 19 files changed, 204 insertions(+), 56 deletions(-) diff --git a/internal/cmd/fmt.go b/internal/cmd/fmt.go index 3c77dbc22e..ffa5833e7f 100644 --- a/internal/cmd/fmt.go +++ b/internal/cmd/fmt.go @@ -188,12 +188,12 @@ func Format(ctx context.Context, dir, filename string, o *Options) (map[string]s continue } // File-level belt for the reprinter path: no formatting result may - // change the file's comments. A violation is a formatter bug; keep - // the file as written and say so. + // change the file's comments or its statement count. A violation is + // a formatter bug; keep the file as written and say so. before, err1 := f.ParseFile(strings.NewReader(string(contents))) after, err2 := f.ParseFile(strings.NewReader(formatted)) - if err1 == nil && (err2 != nil || !sameComments(before.Comments, after.Comments)) { - fmt.Fprintf(stderr, "%s: skipped: formatting would alter comments (this is a bug in sqlc fmt)\n", rel) + if err1 == nil && (err2 != nil || len(before.Stmts) != len(after.Stmts) || !sameComments(before.Comments, after.Comments)) { + fmt.Fprintf(stderr, "%s: skipped: formatting would alter the file (this is a bug in sqlc fmt)\n", rel) continue } output[file] = formatted diff --git a/internal/compiler/output_columns.go b/internal/compiler/output_columns.go index 76b63eb365..557fb7d575 100644 --- a/internal/compiler/output_columns.go +++ b/internal/compiler/output_columns.go @@ -453,7 +453,7 @@ func isTableRequired(n ast.Node, col *Column, prior int) int { return helper(tableOptional, tableRequired) case ast.JoinTypeFull: return helper(tableOptional, tableOptional) - case ast.JoinTypeInner: + case ast.JoinTypeInner, ast.JoinTypeCross, ast.JoinTypeComma: return helper(tableRequired, tableRequired) } case *ast.List: diff --git a/internal/endtoend/testdata/fmt/sqlite/query.sql b/internal/endtoend/testdata/fmt/sqlite/query.sql index eac3f3997f..2856ca935b 100644 --- a/internal/endtoend/testdata/fmt/sqlite/query.sql +++ b/internal/endtoend/testdata/fmt/sqlite/query.sql @@ -65,3 +65,43 @@ CREATE VIRTUAL TABLE recipes_fts USING fts5( name, ingredients ); + +-- name: LoginName :one +SELECT COALESCE(bio, '') AS login FROM authors WHERE id = ? LIMIT 1; + +-- name: SpelledJoins :many +SELECT a.id +FROM authors AS a +INNER JOIN authors AS b ON a.id = b.id +LEFT OUTER JOIN authors AS c ON a.id = c.id +WHERE a.id != ? AND b.id == ? AND c.id <> ?; + +-- name: CommaJoin :one +SELECT count(*) FROM authors AS a, authors AS b WHERE a.id = b.id; + +-- name: PlannerHint :many +SELECT a.id FROM authors AS a CROSS JOIN authors AS b; + +-- name: NumberedParams :many +SELECT id FROM authors WHERE name = ?2 AND bio = ?1; + +-- name: NewestAndOldest :many +SELECT id FROM authors +UNION +SELECT id FROM authors; + +-- name: QuickUnion :many +SELECT id FROM authors UNION ALL SELECT id FROM authors; + +-- name: EnableForeignKeys :exec +PRAGMA foreign_keys = 1; + +-- name: UpsertAuthor :exec +INSERT INTO authors (id, name) +VALUES (?, ?) +ON CONFLICT (id) DO UPDATE SET + name = excluded.name +WHERE excluded.name <> ''; + +-- name: QuickUpsert :exec +INSERT INTO authors (id, name) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET name = excluded.name; diff --git a/internal/endtoend/testdata/fmt/sqlite/stdout.txt b/internal/endtoend/testdata/fmt/sqlite/stdout.txt index d7572ead96..b9201e3620 100644 --- a/internal/endtoend/testdata/fmt/sqlite/stdout.txt +++ b/internal/endtoend/testdata/fmt/sqlite/stdout.txt @@ -64,3 +64,21 @@ -- name: MakeRecipeIndex :exec CREATE VIRTUAL TABLE recipes_fts USING fts5( +@@ -67,7 +74,7 @@ + ); + + -- name: LoginName :one ++SELECT coalesce(bio, '') AS login FROM authors WHERE id = ? LIMIT 1; +-SELECT COALESCE(bio, '') AS login FROM authors WHERE id = ? LIMIT 1; + + -- name: SpelledJoins :many + SELECT a.id +@@ -74,6 +81,6 @@ + FROM authors AS a ++JOIN authors AS b ON a.id = b.id ++LEFT JOIN authors AS c ON a.id = c.id +-INNER JOIN authors AS b ON a.id = b.id +-LEFT OUTER JOIN authors AS c ON a.id = c.id + WHERE a.id != ? AND b.id == ? AND c.id <> ?; + + -- name: CommaJoin :one diff --git a/internal/engine/clickhouse/format.go b/internal/engine/clickhouse/format.go index 997af7d418..5d3cf1090b 100644 --- a/internal/engine/clickhouse/format.go +++ b/internal/engine/clickhouse/format.go @@ -18,7 +18,7 @@ func (p *Parser) TypeName(ns, name string) string { // Param returns the parameter placeholder for the given number. // ClickHouse uses {name:Type} for named parameters, but for positional // parameters we use ? which is supported by the clickhouse-go driver. -func (p *Parser) Param(n int) string { +func (p *Parser) Param(n int, numbered bool) string { return "?" } diff --git a/internal/engine/dolphin/format.go b/internal/engine/dolphin/format.go index 458ae02363..b9b6c40a09 100644 --- a/internal/engine/dolphin/format.go +++ b/internal/engine/dolphin/format.go @@ -25,7 +25,7 @@ func (p *Parser) TypeName(ns, name string) string { // Param returns the parameter placeholder for the given number. // MySQL uses ? for all parameters (positional). -func (p *Parser) Param(n int) string { +func (p *Parser) Param(n int, numbered bool) string { return "?" } diff --git a/internal/engine/postgresql/convert.go b/internal/engine/postgresql/convert.go index b1f746d193..6600ce2151 100644 --- a/internal/engine/postgresql/convert.go +++ b/internal/engine/postgresql/convert.go @@ -1868,8 +1868,16 @@ func convertJoinExpr(n *pg.JoinExpr) *ast.JoinExpr { if n == nil { return nil } + jointype := ast.JoinType(n.Jointype) + // PostgreSQL parses CROSS JOIN as an inner join with no condition — + // the only inner join its grammar allows without one — so that shape + // is CROSS JOIN, and must print as it: a bare JOIN with no ON or + // USING is a syntax error in PostgreSQL. + if jointype == ast.JoinTypeInner && !n.IsNatural && n.Quals == nil && len(n.UsingClause) == 0 { + jointype = ast.JoinTypeCross + } return &ast.JoinExpr{ - Jointype: ast.JoinType(n.Jointype), + Jointype: jointype, IsNatural: n.IsNatural, Larg: convertNode(n.Larg), Rarg: convertNode(n.Rarg), diff --git a/internal/engine/postgresql/reserved.go b/internal/engine/postgresql/reserved.go index 8b826f3317..12522fea94 100644 --- a/internal/engine/postgresql/reserved.go +++ b/internal/engine/postgresql/reserved.go @@ -59,8 +59,8 @@ func (p *Parser) TypeName(ns, name string) string { } // Param returns the parameter placeholder for the given number. -// PostgreSQL uses $1, $2, etc. -func (p *Parser) Param(n int) string { +// PostgreSQL numbers every parameter: $1, $2, etc. +func (p *Parser) Param(n int, numbered bool) string { return fmt.Sprintf("$%d", n) } diff --git a/internal/engine/sqlite/convert.go b/internal/engine/sqlite/convert.go index a4e2364e89..dad36d4d1e 100644 --- a/internal/engine/sqlite/convert.go +++ b/internal/engine/sqlite/convert.go @@ -770,7 +770,11 @@ func (c *cc) convertFrom(refs []*meyer.TableRef) []ast.Node { join.Jointype = ast.JoinTypeLeft case right: join.Jointype = ast.JoinTypeRight - case op.Type&meyer.JoinComma == 0: + case op.Type&meyer.JoinComma != 0: + join.Jointype = ast.JoinTypeComma + case op.Type&meyer.JoinCross != 0: + join.Jointype = ast.JoinTypeCross + default: join.Jointype = ast.JoinTypeInner } } @@ -960,14 +964,38 @@ func (c *cc) convertBinaryExpr(n *meyer.BinaryExpr) ast.Node { Location: n.Pos(), } } + // SQLite spells some operators two ways (<> and !=, = and ==) and the + // tree keeps only the kind, so read the author's choice back out of the + // source between the operands; the compiler recognizes every spelling. + op := n.Op.String() + switch n.Op { + case meyer.OpNe: + if strings.Contains(c.operatorText(n.X, n.Y), "!=") { + op = "!=" + } + case meyer.OpEq: + if strings.Contains(c.operatorText(n.X, n.Y), "==") { + op = "==" + } + } return &ast.A_Expr{ - Name: &ast.List{Items: []ast.Node{&ast.String{Str: n.Op.String()}}}, + Name: &ast.List{Items: []ast.Node{&ast.String{Str: op}}}, Lexpr: c.convert(n.X), Rexpr: c.convert(n.Y), Location: n.Pos(), } } +// operatorText returns the source text separating two adjacent operands, +// where the operator token sits. +func (c *cc) operatorText(x, y meyer.Expr) string { + start, end := x.End(), y.Pos() + if start < 0 || end > len(c.src) || start > end { + return "" + } + return c.src[start:end] +} + func (c *cc) convertUnaryExpr(n *meyer.UnaryExpr) ast.Node { expr := c.convert(n.X) switch n.Op { diff --git a/internal/engine/sqlite/format.go b/internal/engine/sqlite/format.go index 374c23b189..d79e30d45e 100644 --- a/internal/engine/sqlite/format.go +++ b/internal/engine/sqlite/format.go @@ -1,6 +1,9 @@ package sqlite -import "strings" +import ( + "strconv" + "strings" +) // QuoteIdent quotes an identifier when printing it bare would change what it // names: the parser folds unquoted identifiers to lower case, so any name @@ -38,9 +41,14 @@ func (p *Parser) TypeName(ns, name string) string { return name } -// Param returns the parameter placeholder for the given number. -// SQLite uses ? for positional parameters. -func (p *Parser) Param(n int) string { +// Param returns the parameter placeholder for the given number. SQLite +// takes both a bare ? (the next index) and an explicit ?N, and they are +// not interchangeable — reordered ?N parameters bind by their numbers — +// so the one the author wrote is the one printed. +func (p *Parser) Param(n int, numbered bool) string { + if numbered { + return "?" + strconv.Itoa(n) + } return "?" } diff --git a/internal/engine/sqlite/parse.go b/internal/engine/sqlite/parse.go index 325dab2cdd..ce0a729b4c 100644 --- a/internal/engine/sqlite/parse.go +++ b/internal/engine/sqlite/parse.go @@ -32,7 +32,17 @@ func (p *Parser) Parse(r io.Reader) ([]ast.Statement, error) { if err != nil { return nil, err } - return f.Stmts, nil + // The compiler skips statements sqlc has no node for (PRAGMA and + // friends); the formatter must see them, so the filter lives here, + // not in ParseFile. + var stmts []ast.Statement + for _, stmt := range f.Stmts { + if _, ok := stmt.Raw.Stmt.(*ast.TODO); ok { + continue + } + stmts = append(stmts, stmt) + } + return stmts, nil } // ParseFile parses like Parse and also carries the file's comments, taken @@ -55,16 +65,16 @@ func (p *Parser) ParseFile(r io.Reader) (*ast.File, error) { loc := 0 for _, raw := range parsed.Stmts { converter := &cc{src: src} - out := converter.convert(raw) - if _, ok := out.(*ast.TODO); !ok { - stmts = append(stmts, ast.Statement{ - Raw: &ast.RawStmt{ - Stmt: out, - StmtLocation: loc, - StmtLen: trimTerminator(src, raw) - loc, - }, - }) - } + // A statement sqlc has no node for converts to a TODO and stays in + // the list: the formatter needs its extent to keep it as written, + // and Parse filters it out for the compiler. + stmts = append(stmts, ast.Statement{ + Raw: &ast.RawStmt{ + Stmt: converter.convert(raw), + StmtLocation: loc, + StmtLen: trimTerminator(src, raw) - loc, + }, + }) loc = raw.End() } diff --git a/internal/sql/ast/a_expr.go b/internal/sql/ast/a_expr.go index 2605db59d6..ea3242337c 100644 --- a/internal/sql/ast/a_expr.go +++ b/internal/sql/ast/a_expr.go @@ -7,7 +7,14 @@ import ( ) type A_Expr struct { - Kind A_Expr_Kind + Kind A_Expr_Kind + // Name is the operator, as a list of String nodes: PostgreSQL's + // operator space is open (user-defined and schema-qualified operators), + // so the shared tree keeps pg_query's shape rather than an enum. Each + // engine's converter writes the operator as its parser saw it — for an + // engine that accepts more than one spelling of the same operator + // (SQLite's != for <>, == for =), that is the author's spelling, which + // is how the printer preserves it. Name *List Lexpr Node Rexpr Node diff --git a/internal/sql/ast/coalesce_expr.go b/internal/sql/ast/coalesce_expr.go index 0faee5bf4c..6aadffd30c 100644 --- a/internal/sql/ast/coalesce_expr.go +++ b/internal/sql/ast/coalesce_expr.go @@ -18,7 +18,9 @@ func (n *CoalesceExpr) Format(buf *TrackedBuffer, d format.Dialect) { if n == nil { return } - buf.WriteString("COALESCE(") + // Lower case, like every other function name: the printer upper-cases + // keywords, and function names are identifiers, which fold lower. + buf.WriteString("coalesce(") buf.astFormat(n.Args, d) buf.WriteString(")") } diff --git a/internal/sql/ast/join_expr.go b/internal/sql/ast/join_expr.go index c682356660..a6bd132d7c 100644 --- a/internal/sql/ast/join_expr.go +++ b/internal/sql/ast/join_expr.go @@ -22,27 +22,28 @@ func (n *JoinExpr) Format(buf *TrackedBuffer, d format.Dialect) { return } buf.astFormat(n.Larg, d) - buf.beforeClause(n.Rarg, d) - buf.Line() - if n.IsNatural { - buf.WriteString("NATURAL ") - } - switch n.Jointype { - case JoinTypeLeft: - buf.WriteString("LEFT JOIN ") - case JoinTypeRight: - buf.WriteString("RIGHT JOIN ") - case JoinTypeFull: - buf.WriteString("FULL JOIN ") - case JoinTypeInner: - // CROSS JOIN has no ON or USING clause - if !items(n.UsingClause) && !set(n.Quals) { + if n.Jointype == JoinTypeComma { + buf.WriteString(",") + buf.beforeClause(n.Rarg, d) + buf.Line() + } else { + buf.beforeClause(n.Rarg, d) + buf.Line() + if n.IsNatural { + buf.WriteString("NATURAL ") + } + switch n.Jointype { + case JoinTypeLeft: + buf.WriteString("LEFT JOIN ") + case JoinTypeRight: + buf.WriteString("RIGHT JOIN ") + case JoinTypeFull: + buf.WriteString("FULL JOIN ") + case JoinTypeCross: buf.WriteString("CROSS JOIN ") - } else { + default: buf.WriteString("JOIN ") } - default: - buf.WriteString("JOIN ") } buf.astFormat(n.Rarg, d) if items(n.UsingClause) { diff --git a/internal/sql/ast/join_type.go b/internal/sql/ast/join_type.go index 824e0b357f..d4f5565b80 100644 --- a/internal/sql/ast/join_type.go +++ b/internal/sql/ast/join_type.go @@ -12,6 +12,13 @@ const ( JoinTypeAnti JoinTypeUniqueOuter JoinTypeUniqueInner + // Beyond the libpg_query set: joins SQLite spells (and treats) + // distinctly. Both behave as inner joins, but CROSS JOIN carries a + // planner hint — SQLite will not reorder the pair — and a + // comma-separated FROM item is its own syntax, so neither may be + // rewritten into the other. + JoinTypeCross + JoinTypeComma ) type JoinType uint diff --git a/internal/sql/ast/on_conflict_clause.go b/internal/sql/ast/on_conflict_clause.go index a71bae0a23..7e04c7ff52 100644 --- a/internal/sql/ast/on_conflict_clause.go +++ b/internal/sql/ast/on_conflict_clause.go @@ -35,12 +35,20 @@ func (n *OnConflictClause) Format(buf *TrackedBuffer, d format.Dialect) { case OnConflictActionNothing: buf.WriteString("DO NOTHING") case OnConflictActionUpdate: - buf.WriteString("DO UPDATE SET ") - // Format as assignment list: name = val + buf.WriteString("DO UPDATE SET") + buf.Group() + buf.Indent() + // Format as assignment list: name = val, one per line when the + // author broke the list (or a comment forces it open). if n.TargetList != nil { for i, item := range n.TargetList.Items { - if i > 0 { - buf.WriteString(", ") + if i == 0 { + buf.boundary(item) + buf.Line() + } else { + buf.WriteString(",") + buf.boundary(item) + buf.Line() } if rt, ok := item.(*ResTarget); ok { if rt.Name != nil { @@ -53,9 +61,13 @@ func (n *OnConflictClause) Format(buf *TrackedBuffer, d format.Dialect) { } } } + buf.EndIndent() if set(n.WhereClause) { - buf.WriteString(" WHERE ") - buf.astFormat(n.WhereClause, d) + buf.boundary(n.WhereClause) + buf.Line() + buf.WriteString("WHERE ") + buf.condition(n.WhereClause, d) } + buf.EndGroup() } } diff --git a/internal/sql/ast/param_ref.go b/internal/sql/ast/param_ref.go index 7ebc897a95..02c98f3dfb 100644 --- a/internal/sql/ast/param_ref.go +++ b/internal/sql/ast/param_ref.go @@ -16,5 +16,5 @@ func (n *ParamRef) Format(buf *TrackedBuffer, d format.Dialect) { if n == nil { return } - buf.WriteString(d.Param(n.Number)) + buf.WriteString(d.Param(n.Number, n.Dollar)) } diff --git a/internal/sql/ast/select_stmt.go b/internal/sql/ast/select_stmt.go index 2b41692bff..226c110734 100644 --- a/internal/sql/ast/select_stmt.go +++ b/internal/sql/ast/select_stmt.go @@ -78,6 +78,10 @@ func (n *SelectStmt) Format(buf *TrackedBuffer, d format.Dialect) { if n.Larg != nil && n.Rarg != nil { buf.astFormat(n.Larg, d) + // The seam between the compound halves: an author who broke the + // line around UNION / INTERSECT / EXCEPT keeps the operator on its + // own line, and a comment above it prints here. + buf.boundary(n.Rarg) buf.Line() switch n.Op { case Union: diff --git a/internal/sql/format/format.go b/internal/sql/format/format.go index 1520cb2358..b61b9cf5e7 100644 --- a/internal/sql/format/format.go +++ b/internal/sql/format/format.go @@ -10,9 +10,12 @@ type Dialect interface { // This handles dialect-specific type name mappings (e.g., pg_catalog.int4 -> integer) TypeName(ns, name string) string - // Param returns the parameter placeholder for the given parameter number. + // Param returns the placeholder for the parameter with this number. + // numbered reports that the author wrote the number out (SQLite's ?2, + // where a bare ? takes the next index), so engines with both forms can + // keep the one that was written. // PostgreSQL uses $1, $2, etc. MySQL uses ? - Param(n int) string + Param(n int, numbered bool) string // Cast formats a type cast expression. // PostgreSQL uses expr::type, MySQL uses CAST(expr AS type) From 465f4a9053dc46d28601522b6e530974fe74b515 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 27 Aug 2026 17:55:44 +0000 Subject: [PATCH 2/2] endtoend: run sqlc fmt over the sqlite testdata queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Format every sqlite query file in the end-to-end corpus with the new formatter and regenerate the affected goldens (the generated code embeds the query text). The fmt case's own input stays unformatted — it is the formatter's fixture — and nine files are left as written because they only parse after the compiler's preprocessing (sqlc.arg/narg/slice/ embed, @named parameters). Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_018MTvpHqNMadH12pTtsgUq2 --- .../between_args/sqlite/go/query.sql.go | 18 ++--- .../testdata/between_args/sqlite/query.sql | 18 ++--- .../builtins/sqlite/go/mathfunc.sql.go | 58 +++++++-------- .../builtins/sqlite/queries/mathfunc.sql | 58 +++++++-------- .../case_sensitive/sqlite/go/query.sql.go | 6 +- .../testdata/case_sensitive/sqlite/query.sql | 7 +- .../testdata/coalesce/sqlite/go/query.sql.go | 2 +- .../testdata/coalesce/sqlite/query.sql | 2 +- .../coalesce_as/sqlite/go/query.sql.go | 2 +- .../testdata/coalesce_as/sqlite/query.sql | 2 +- .../testdata/column_as/sqlite/go/query.sql.go | 2 +- .../testdata/column_as/sqlite/query.sql | 2 +- .../testdata/comparisons/sqlite/query.sql | 6 -- .../count_star/sqlite/go/query.sql.go | 2 +- .../testdata/count_star/sqlite/query.sql | 2 +- .../datatype/sqlite/sql/character.sql | 32 ++++----- .../testdata/datatype/sqlite/sql/datetime.sql | 12 ++-- .../testdata/datatype/sqlite/sql/numeric.sql | 60 ++++++++-------- .../sqlite/go/query.sql.go | 2 +- .../sqlite/query.sql | 2 +- .../sqlite/go/query.sql.go | 4 +- .../sqlite/query.sql | 4 +- .../sqlite/go/query.sql.go | 2 +- .../sqlite/query.sql | 2 +- .../sqlite/go/query.sql.go | 2 +- .../ddl_alter_table_rename/sqlite/query.sql | 2 +- .../sqlite/go/query.sql.go | 2 +- .../sqlite/query.sql | 2 +- .../sqlite/go/query.sql.go | 6 +- .../experiment_coreanalyzer/sqlite/query.sql | 6 +- .../full_outer_join/sqlite/go/query.sql.go | 9 +-- .../testdata/full_outer_join/sqlite/query.sql | 9 +-- .../func_call_cast/sqlite/go/query.sql.go | 2 +- .../testdata/func_call_cast/sqlite/query.sql | 2 +- .../func_match_types/sqlite/go/query.sql.go | 6 +- .../func_match_types/sqlite/query.sql | 6 +- .../testdata/inflection/sqlite/query.sql | 2 +- .../insert_default_values/sqlite/query.sql | 2 +- .../insert_select/sqlite/go/query.sql.go | 3 +- .../testdata/insert_select/sqlite/query.sql | 3 +- .../testdata/insert_values/sqlite/query.sql | 2 +- .../sqlite/query.sql | 4 +- .../invalid_table_alias/sqlite/query.sql | 8 +-- .../join_alias/sqlite/go/query.sql.go | 8 +-- .../testdata/join_alias/sqlite/query.sql | 8 +-- .../testdata/join_left/sqlite/go/query.sql.go | 72 +++++++++---------- .../testdata/join_left/sqlite/query.sql | 72 +++++++++---------- .../sqlite/go/query.sql.go | 14 ++-- .../join_left_same_table/sqlite/query.sql | 14 ++-- .../join_where_clause/sqlite/query.sql | 2 +- .../testdata/jsonb/sqlite/go/query.sql.go | 38 +++++----- .../endtoend/testdata/jsonb/sqlite/query.sql | 38 +++++----- .../multibyte_comment/sqlite/go/query.sql.go | 4 +- .../multibyte_comment/sqlite/query.sql | 4 +- .../quoted_colname/sqlite/go/query.sql.go | 2 +- .../testdata/quoted_colname/sqlite/query.sql | 2 +- .../testdata/returning/sqlite/go/query.sql.go | 32 +++++---- .../testdata/returning/sqlite/query.sql | 32 +++++---- .../select_exists/sqlite/go/query.sql.go | 13 ++-- .../testdata/select_exists/sqlite/query.sql | 13 ++-- .../select_in_and/sqlite/go/query.sql.go | 26 +++---- .../testdata/select_in_and/sqlite/query.sql | 28 +++----- .../select_limit/sqlite/go/query.sql.go | 9 ++- .../testdata/select_limit/sqlite/query.sql | 9 ++- .../sqlite/go/query.sql.go | 11 +-- .../select_nested_count/sqlite/query.sql | 11 +-- .../select_not_exists/sqlite/go/query.sql.go | 13 ++-- .../select_not_exists/sqlite/query.sql | 14 ++-- .../select_star/sqlite/go/query.sql.go | 2 +- .../testdata/select_star/sqlite/query.sql | 2 +- .../select_union/sqlite/go/query.sql.go | 3 +- .../testdata/select_union/sqlite/query.sql | 3 +- .../sqlite/go/query.sql.go | 24 +++---- .../single_param_conflict/sqlite/query.sql | 24 +++---- .../testdata/sqlite_skip_todo/db/query.sql.go | 3 +- .../testdata/sqlite_skip_todo/query.sql | 4 +- .../sqlite/go/query.sql.go | 6 +- .../sqlite_table_options/sqlite/query.sql | 6 +- .../star_expansion/sqlite/go/query.sql.go | 2 +- .../testdata/star_expansion/sqlite/query.sql | 2 +- .../sqlite/go/query.sql.go | 4 +- .../star_expansion_core/sqlite/query.sql | 4 +- .../table_function/sqlite/go/query.sql.go | 15 ++-- .../testdata/table_function/sqlite/query.sql | 15 ++-- .../sqlite/go/query.sql.go | 8 +-- .../sqlite/query.sql | 8 +-- .../sqlite/stdlib/db/query.sql.go | 2 +- .../untyped_columns/sqlite/stdlib/query.sql | 2 +- .../testdata/upsert/sqlite/go/query.sql.go | 22 +++--- .../endtoend/testdata/upsert/sqlite/query.sql | 22 +++--- .../virtual_table/sqlite/go/query.sql.go | 23 +++--- .../testdata/virtual_table/sqlite/query.sql | 23 +++--- .../sqlite/go/query.sql.go | 9 ++- .../sqlite/query.sql | 9 ++- .../where_collate/sqlite/go/query.sql.go | 5 +- .../testdata/where_collate/sqlite/query.sql | 7 +- 96 files changed, 570 insertions(+), 563 deletions(-) diff --git a/internal/endtoend/testdata/between_args/sqlite/go/query.sql.go b/internal/endtoend/testdata/between_args/sqlite/go/query.sql.go index 6ee3292017..2083abf243 100644 --- a/internal/endtoend/testdata/between_args/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/between_args/sqlite/go/query.sql.go @@ -10,9 +10,9 @@ import ( ) const getBetweenPrices = `-- name: GetBetweenPrices :many -SELECT name, price -FROM products -WHERE price BETWEEN ? AND ? +SELECT name, price +FROM products +WHERE price BETWEEN ? AND ? ` type GetBetweenPricesParams struct { @@ -44,9 +44,9 @@ func (q *Queries) GetBetweenPrices(ctx context.Context, arg GetBetweenPricesPara } const getBetweenPricesTable = `-- name: GetBetweenPricesTable :many -SELECT name, price -FROM products -WHERE products.price BETWEEN ? AND ? +SELECT name, price +FROM products +WHERE products.price BETWEEN ? AND ? ` type GetBetweenPricesTableParams struct { @@ -78,9 +78,9 @@ func (q *Queries) GetBetweenPricesTable(ctx context.Context, arg GetBetweenPrice } const getBetweenPricesTableAlias = `-- name: GetBetweenPricesTableAlias :many -SELECT name, price -FROM products as p -WHERE p.price BETWEEN ? AND ? +SELECT name, price +FROM products AS p +WHERE p.price BETWEEN ? AND ? ` type GetBetweenPricesTableAliasParams struct { diff --git a/internal/endtoend/testdata/between_args/sqlite/query.sql b/internal/endtoend/testdata/between_args/sqlite/query.sql index a7648ca582..14dd15f06f 100644 --- a/internal/endtoend/testdata/between_args/sqlite/query.sql +++ b/internal/endtoend/testdata/between_args/sqlite/query.sql @@ -1,14 +1,14 @@ -- name: GetBetweenPrices :many -SELECT * -FROM products -WHERE price BETWEEN ? AND ?; +SELECT * +FROM products +WHERE price BETWEEN ? AND ?; -- name: GetBetweenPricesTable :many -SELECT * -FROM products -WHERE products.price BETWEEN ? AND ?; +SELECT * +FROM products +WHERE products.price BETWEEN ? AND ?; -- name: GetBetweenPricesTableAlias :many -SELECT * -FROM products as p -WHERE p.price BETWEEN ? AND ?; +SELECT * +FROM products AS p +WHERE p.price BETWEEN ? AND ?; diff --git a/internal/endtoend/testdata/builtins/sqlite/go/mathfunc.sql.go b/internal/endtoend/testdata/builtins/sqlite/go/mathfunc.sql.go index f366b19836..30ae799ce5 100644 --- a/internal/endtoend/testdata/builtins/sqlite/go/mathfunc.sql.go +++ b/internal/endtoend/testdata/builtins/sqlite/go/mathfunc.sql.go @@ -10,7 +10,7 @@ import ( ) const getAcos = `-- name: GetAcos :one -select acos(1.0) +SELECT acos(1.0) ` func (q *Queries) GetAcos(ctx context.Context) (float64, error) { @@ -21,7 +21,7 @@ func (q *Queries) GetAcos(ctx context.Context) (float64, error) { } const getAcosh = `-- name: GetAcosh :one -select acosh(1.0) +SELECT acosh(1.0) ` func (q *Queries) GetAcosh(ctx context.Context) (float64, error) { @@ -32,7 +32,7 @@ func (q *Queries) GetAcosh(ctx context.Context) (float64, error) { } const getAsin = `-- name: GetAsin :one -select asin(1.0) +SELECT asin(1.0) ` func (q *Queries) GetAsin(ctx context.Context) (float64, error) { @@ -43,7 +43,7 @@ func (q *Queries) GetAsin(ctx context.Context) (float64, error) { } const getAsinh = `-- name: GetAsinh :one -select asinh(1.0) +SELECT asinh(1.0) ` func (q *Queries) GetAsinh(ctx context.Context) (float64, error) { @@ -54,7 +54,7 @@ func (q *Queries) GetAsinh(ctx context.Context) (float64, error) { } const getAtan = `-- name: GetAtan :one -select atan(1.0) +SELECT atan(1.0) ` func (q *Queries) GetAtan(ctx context.Context) (float64, error) { @@ -65,7 +65,7 @@ func (q *Queries) GetAtan(ctx context.Context) (float64, error) { } const getAtan2 = `-- name: GetAtan2 :one -select atan2(1.0, 0.5) +SELECT atan2(1.0, 0.5) ` func (q *Queries) GetAtan2(ctx context.Context) (float64, error) { @@ -76,7 +76,7 @@ func (q *Queries) GetAtan2(ctx context.Context) (float64, error) { } const getAtanh = `-- name: GetAtanh :one -select atanh(1.0) +SELECT atanh(1.0) ` func (q *Queries) GetAtanh(ctx context.Context) (float64, error) { @@ -87,7 +87,7 @@ func (q *Queries) GetAtanh(ctx context.Context) (float64, error) { } const getCeil = `-- name: GetCeil :one -select ceil(1.0) +SELECT ceil(1.0) ` func (q *Queries) GetCeil(ctx context.Context) (int64, error) { @@ -98,7 +98,7 @@ func (q *Queries) GetCeil(ctx context.Context) (int64, error) { } const getCeilin = `-- name: GetCeilin :one -select ceiling(1.0) +SELECT ceiling(1.0) ` func (q *Queries) GetCeilin(ctx context.Context) (int64, error) { @@ -109,7 +109,7 @@ func (q *Queries) GetCeilin(ctx context.Context) (int64, error) { } const getCos = `-- name: GetCos :one -select cos(1.0) +SELECT cos(1.0) ` func (q *Queries) GetCos(ctx context.Context) (float64, error) { @@ -120,7 +120,7 @@ func (q *Queries) GetCos(ctx context.Context) (float64, error) { } const getCosh = `-- name: GetCosh :one -select cosh(1.0) +SELECT cosh(1.0) ` func (q *Queries) GetCosh(ctx context.Context) (float64, error) { @@ -131,7 +131,7 @@ func (q *Queries) GetCosh(ctx context.Context) (float64, error) { } const getDegrees = `-- name: GetDegrees :one -select degrees(1.0) +SELECT degrees(1.0) ` func (q *Queries) GetDegrees(ctx context.Context) (float64, error) { @@ -142,7 +142,7 @@ func (q *Queries) GetDegrees(ctx context.Context) (float64, error) { } const getExp = `-- name: GetExp :one -select exp(1.0) +SELECT exp(1.0) ` func (q *Queries) GetExp(ctx context.Context) (float64, error) { @@ -153,7 +153,7 @@ func (q *Queries) GetExp(ctx context.Context) (float64, error) { } const getFloor = `-- name: GetFloor :one -select floor(1.0) +SELECT floor(1.0) ` func (q *Queries) GetFloor(ctx context.Context) (int64, error) { @@ -164,7 +164,7 @@ func (q *Queries) GetFloor(ctx context.Context) (int64, error) { } const getLn = `-- name: GetLn :one -select ln(1.0) +SELECT ln(1.0) ` func (q *Queries) GetLn(ctx context.Context) (float64, error) { @@ -175,7 +175,7 @@ func (q *Queries) GetLn(ctx context.Context) (float64, error) { } const getLog = `-- name: GetLog :one -select log(1.0) +SELECT log(1.0) ` func (q *Queries) GetLog(ctx context.Context) (float64, error) { @@ -186,7 +186,7 @@ func (q *Queries) GetLog(ctx context.Context) (float64, error) { } const getLog10 = `-- name: GetLog10 :one -select log10(1.0) +SELECT log10(1.0) ` func (q *Queries) GetLog10(ctx context.Context) (float64, error) { @@ -197,7 +197,7 @@ func (q *Queries) GetLog10(ctx context.Context) (float64, error) { } const getLog2 = `-- name: GetLog2 :one -select log2(1.0) +SELECT log2(1.0) ` func (q *Queries) GetLog2(ctx context.Context) (float64, error) { @@ -208,7 +208,7 @@ func (q *Queries) GetLog2(ctx context.Context) (float64, error) { } const getLogBase = `-- name: GetLogBase :one -select log(1.0, 2.0) +SELECT log(1.0, 2.0) ` func (q *Queries) GetLogBase(ctx context.Context) (float64, error) { @@ -219,7 +219,7 @@ func (q *Queries) GetLogBase(ctx context.Context) (float64, error) { } const getMod = `-- name: GetMod :one -select mod(1, 2) +SELECT mod(1, 2) ` func (q *Queries) GetMod(ctx context.Context) (float64, error) { @@ -230,7 +230,7 @@ func (q *Queries) GetMod(ctx context.Context) (float64, error) { } const getPi = `-- name: GetPi :one -select pi() +SELECT pi() ` func (q *Queries) GetPi(ctx context.Context) (float64, error) { @@ -241,7 +241,7 @@ func (q *Queries) GetPi(ctx context.Context) (float64, error) { } const getPow = `-- name: GetPow :one -select pow(1, 2) +SELECT pow(1, 2) ` func (q *Queries) GetPow(ctx context.Context) (float64, error) { @@ -252,7 +252,7 @@ func (q *Queries) GetPow(ctx context.Context) (float64, error) { } const getPower = `-- name: GetPower :one -select power(1, 2) +SELECT power(1, 2) ` func (q *Queries) GetPower(ctx context.Context) (float64, error) { @@ -263,7 +263,7 @@ func (q *Queries) GetPower(ctx context.Context) (float64, error) { } const getRadians = `-- name: GetRadians :one -select radians(1) +SELECT radians(1) ` func (q *Queries) GetRadians(ctx context.Context) (float64, error) { @@ -274,7 +274,7 @@ func (q *Queries) GetRadians(ctx context.Context) (float64, error) { } const getSin = `-- name: GetSin :one -select sin(1.0) +SELECT sin(1.0) ` func (q *Queries) GetSin(ctx context.Context) (float64, error) { @@ -285,7 +285,7 @@ func (q *Queries) GetSin(ctx context.Context) (float64, error) { } const getSinh = `-- name: GetSinh :one -select sinh(1.0) +SELECT sinh(1.0) ` func (q *Queries) GetSinh(ctx context.Context) (float64, error) { @@ -296,7 +296,7 @@ func (q *Queries) GetSinh(ctx context.Context) (float64, error) { } const getSqrt = `-- name: GetSqrt :one -select sqrt(1.0) +SELECT sqrt(1.0) ` func (q *Queries) GetSqrt(ctx context.Context) (float64, error) { @@ -307,7 +307,7 @@ func (q *Queries) GetSqrt(ctx context.Context) (float64, error) { } const getTan = `-- name: GetTan :one -select tan(1.0) +SELECT tan(1.0) ` func (q *Queries) GetTan(ctx context.Context) (float64, error) { @@ -318,7 +318,7 @@ func (q *Queries) GetTan(ctx context.Context) (float64, error) { } const getTrunc = `-- name: GetTrunc :one -select trunc(1.0) +SELECT trunc(1.0) ` func (q *Queries) GetTrunc(ctx context.Context) (int64, error) { diff --git a/internal/endtoend/testdata/builtins/sqlite/queries/mathfunc.sql b/internal/endtoend/testdata/builtins/sqlite/queries/mathfunc.sql index d62c2b6521..cf3e2f5c44 100644 --- a/internal/endtoend/testdata/builtins/sqlite/queries/mathfunc.sql +++ b/internal/endtoend/testdata/builtins/sqlite/queries/mathfunc.sql @@ -1,86 +1,86 @@ -- name: GetAcos :one -select acos(1.0); +SELECT acos(1.0); -- name: GetAcosh :one -select acosh(1.0); +SELECT acosh(1.0); -- name: GetAsin :one -select asin(1.0); +SELECT asin(1.0); -- name: GetAsinh :one -select asinh(1.0); +SELECT asinh(1.0); -- name: GetAtan :one -select atan(1.0); +SELECT atan(1.0); -- name: GetAtan2 :one -select atan2(1.0, 0.5); +SELECT atan2(1.0, 0.5); -- name: GetAtanh :one -select atanh(1.0); +SELECT atanh(1.0); -- name: GetCeil :one -select ceil(1.0); +SELECT ceil(1.0); -- name: GetCeilin :one -select ceiling(1.0); +SELECT ceiling(1.0); -- name: GetCos :one -select cos(1.0); +SELECT cos(1.0); -- name: GetCosh :one -select cosh(1.0); +SELECT cosh(1.0); -- name: GetDegrees :one -select degrees(1.0); +SELECT degrees(1.0); -- name: GetExp :one -select exp(1.0); +SELECT exp(1.0); -- name: GetFloor :one -select floor(1.0); +SELECT floor(1.0); -- name: GetLn :one -select ln(1.0); +SELECT ln(1.0); -- name: GetLog :one -select log(1.0); +SELECT log(1.0); -- name: GetLog10 :one -select log10(1.0); +SELECT log10(1.0); -- name: GetLogBase :one -select log(1.0, 2.0); +SELECT log(1.0, 2.0); -- name: GetLog2 :one -select log2(1.0); +SELECT log2(1.0); -- name: GetMod :one -select mod(1, 2); +SELECT mod(1, 2); -- name: GetPi :one -select pi(); +SELECT pi(); -- name: GetPow :one -select pow(1, 2); +SELECT pow(1, 2); -- name: GetPower :one -select power(1, 2); +SELECT power(1, 2); -- name: GetRadians :one -select radians(1); +SELECT radians(1); -- name: GetSin :one -select sin(1.0); +SELECT sin(1.0); -- name: GetSinh :one -select sinh(1.0); +SELECT sinh(1.0); -- name: GetSqrt :one -select sqrt(1.0); +SELECT sqrt(1.0); -- name: GetTan :one -select tan(1.0); +SELECT tan(1.0); -- name: GetTrunc :one -select trunc(1.0); +SELECT trunc(1.0); diff --git a/internal/endtoend/testdata/case_sensitive/sqlite/go/query.sql.go b/internal/endtoend/testdata/case_sensitive/sqlite/go/query.sql.go index 434a9ef40e..a1c5a532e4 100644 --- a/internal/endtoend/testdata/case_sensitive/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/case_sensitive/sqlite/go/query.sql.go @@ -12,10 +12,10 @@ import ( const insertContact = `-- name: InsertContact :exec INSERT INTO contacts ( - pid, - CustomerName + pid, + customername ) -VALUES (?,?) +VALUES (?, ?) ` type InsertContactParams struct { diff --git a/internal/endtoend/testdata/case_sensitive/sqlite/query.sql b/internal/endtoend/testdata/case_sensitive/sqlite/query.sql index 0c05277ef4..20dafb2fc3 100644 --- a/internal/endtoend/testdata/case_sensitive/sqlite/query.sql +++ b/internal/endtoend/testdata/case_sensitive/sqlite/query.sql @@ -1,7 +1,6 @@ -- name: InsertContact :exec INSERT INTO contacts ( - pid, - CustomerName + pid, + customername ) -VALUES (?,?) -; +VALUES (?, ?); diff --git a/internal/endtoend/testdata/coalesce/sqlite/go/query.sql.go b/internal/endtoend/testdata/coalesce/sqlite/go/query.sql.go index c98120bf50..4324a035ac 100644 --- a/internal/endtoend/testdata/coalesce/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/coalesce/sqlite/go/query.sql.go @@ -11,7 +11,7 @@ import ( ) const coalesce = `-- name: Coalesce :many -SELECT coalesce(bar, '') as login +SELECT coalesce(bar, '') AS login FROM foo ` diff --git a/internal/endtoend/testdata/coalesce/sqlite/query.sql b/internal/endtoend/testdata/coalesce/sqlite/query.sql index 4cc0de9e29..f7b1c92a05 100644 --- a/internal/endtoend/testdata/coalesce/sqlite/query.sql +++ b/internal/endtoend/testdata/coalesce/sqlite/query.sql @@ -1,5 +1,5 @@ -- name: Coalesce :many -SELECT coalesce(bar, '') as login +SELECT coalesce(bar, '') AS login FROM foo; -- name: CoalesceColumns :many diff --git a/internal/endtoend/testdata/coalesce_as/sqlite/go/query.sql.go b/internal/endtoend/testdata/coalesce_as/sqlite/go/query.sql.go index 8ce06bb097..556c5b5955 100644 --- a/internal/endtoend/testdata/coalesce_as/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/coalesce_as/sqlite/go/query.sql.go @@ -11,7 +11,7 @@ import ( ) const sumBaz = `-- name: SumBaz :many -SELECT bar, coalesce(sum(baz), 0) as quantity +SELECT bar, coalesce(sum(baz), 0) AS quantity FROM foo GROUP BY 1 ` diff --git a/internal/endtoend/testdata/coalesce_as/sqlite/query.sql b/internal/endtoend/testdata/coalesce_as/sqlite/query.sql index 3f51061f8b..d092958fb9 100644 --- a/internal/endtoend/testdata/coalesce_as/sqlite/query.sql +++ b/internal/endtoend/testdata/coalesce_as/sqlite/query.sql @@ -1,4 +1,4 @@ -- name: SumBaz :many -SELECT bar, coalesce(sum(baz), 0) as quantity +SELECT bar, coalesce(sum(baz), 0) AS quantity FROM foo GROUP BY 1; diff --git a/internal/endtoend/testdata/column_as/sqlite/go/query.sql.go b/internal/endtoend/testdata/column_as/sqlite/go/query.sql.go index 6530033ee7..66d96ac3d9 100644 --- a/internal/endtoend/testdata/column_as/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/column_as/sqlite/go/query.sql.go @@ -26,7 +26,7 @@ func (q *Queries) WithAs(ctx context.Context) (WithAsRow, error) { } const withoutAs = `-- name: WithoutAs :one -SELECT 1 x, 2 y +SELECT 1 AS x, 2 AS y ` type WithoutAsRow struct { diff --git a/internal/endtoend/testdata/column_as/sqlite/query.sql b/internal/endtoend/testdata/column_as/sqlite/query.sql index c7282d88ef..e783582d56 100644 --- a/internal/endtoend/testdata/column_as/sqlite/query.sql +++ b/internal/endtoend/testdata/column_as/sqlite/query.sql @@ -2,4 +2,4 @@ SELECT 1 AS x, 2 AS y; -- name: WithoutAs :one -SELECT 1 x, 2 y; +SELECT 1 AS x, 2 AS y; diff --git a/internal/endtoend/testdata/comparisons/sqlite/query.sql b/internal/endtoend/testdata/comparisons/sqlite/query.sql index 8763edaa62..41ea9ab1a7 100644 --- a/internal/endtoend/testdata/comparisons/sqlite/query.sql +++ b/internal/endtoend/testdata/comparisons/sqlite/query.sql @@ -18,9 +18,3 @@ SELECT count(*) <> 0 FROM bar; -- name: Equal :many SELECT count(*) = 0 FROM bar; - - - - - - diff --git a/internal/endtoend/testdata/count_star/sqlite/go/query.sql.go b/internal/endtoend/testdata/count_star/sqlite/go/query.sql.go index 817ad88789..155bfc114a 100644 --- a/internal/endtoend/testdata/count_star/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/count_star/sqlite/go/query.sql.go @@ -21,7 +21,7 @@ func (q *Queries) CountStarLower(ctx context.Context) (int64, error) { } const countStarUpper = `-- name: CountStarUpper :one -SELECT COUNT(*) FROM bar +SELECT count(*) FROM bar ` func (q *Queries) CountStarUpper(ctx context.Context) (int64, error) { diff --git a/internal/endtoend/testdata/count_star/sqlite/query.sql b/internal/endtoend/testdata/count_star/sqlite/query.sql index 6cba4363c5..4fbc6599a8 100644 --- a/internal/endtoend/testdata/count_star/sqlite/query.sql +++ b/internal/endtoend/testdata/count_star/sqlite/query.sql @@ -2,4 +2,4 @@ SELECT count(*) FROM bar; -- name: CountStarUpper :one -SELECT COUNT(*) FROM bar; +SELECT count(*) FROM bar; diff --git a/internal/endtoend/testdata/datatype/sqlite/sql/character.sql b/internal/endtoend/testdata/datatype/sqlite/sql/character.sql index d4b728bdab..8c5a6ea95c 100644 --- a/internal/endtoend/testdata/datatype/sqlite/sql/character.sql +++ b/internal/endtoend/testdata/datatype/sqlite/sql/character.sql @@ -1,23 +1,23 @@ -- Character Types -- https://www.sqlite.org/datatype3.html CREATE TABLE dt_character ( - a CHARACTER(32), - b VARCHAR(32), - c VARYING CHARACTER(32), - d NCHAR(32), - e NATIVE CHARACTER(32), - f NVARCHAR(32), - g TEXT, - h CLOB + a CHARACTER(32), + b VARCHAR(32), + c VARYING CHARACTER(32), + d NCHAR(32), + e NATIVE CHARACTER(32), + f NVARCHAR(32), + g TEXT, + h CLOB ); CREATE TABLE dt_character_not_null ( - a CHARACTER(32) NOT NULL, - b VARCHAR(32) NOT NULL, - c VARYING CHARACTER(32) NOT NULL, - d NCHAR(32) NOT NULL, - e NATIVE CHARACTER(32) NOT NULL, - f NVARCHAR(32) NOT NULL, - g TEXT NOT NULL, - h CLOB NOT NULL + a CHARACTER(32) NOT NULL, + b VARCHAR(32) NOT NULL, + c VARYING CHARACTER(32) NOT NULL, + d NCHAR(32) NOT NULL, + e NATIVE CHARACTER(32) NOT NULL, + f NVARCHAR(32) NOT NULL, + g TEXT NOT NULL, + h CLOB NOT NULL ); diff --git a/internal/endtoend/testdata/datatype/sqlite/sql/datetime.sql b/internal/endtoend/testdata/datatype/sqlite/sql/datetime.sql index 6008cf6ae6..a1f91e513d 100644 --- a/internal/endtoend/testdata/datatype/sqlite/sql/datetime.sql +++ b/internal/endtoend/testdata/datatype/sqlite/sql/datetime.sql @@ -1,13 +1,13 @@ -- Date/Time Types -- https://www.sqlite.org/datatype3.html CREATE TABLE dt_datetime ( - a DATE, - b DATETIME, - c TIMESTAMP + a DATE, + b DATETIME, + c TIMESTAMP ); CREATE TABLE dt_datetime_not_null ( - a DATE NOT NULL, - b DATETIME NOT NULL, - c TIMESTAMP NOT NULL + a DATE NOT NULL, + b DATETIME NOT NULL, + c TIMESTAMP NOT NULL ); diff --git a/internal/endtoend/testdata/datatype/sqlite/sql/numeric.sql b/internal/endtoend/testdata/datatype/sqlite/sql/numeric.sql index a85b4f295b..1662cb6ce0 100644 --- a/internal/endtoend/testdata/datatype/sqlite/sql/numeric.sql +++ b/internal/endtoend/testdata/datatype/sqlite/sql/numeric.sql @@ -1,37 +1,37 @@ -- Numeric Types -- https://www.sqlite.org/datatype3.html CREATE TABLE dt_numeric ( - a INT, - b INTEGER, - c TINYINT, - d SMALLINT, - e MEDIUMINT, - f BIGINT, - g UNSIGNED BIG INT, - h INT2, - i INT8, - j REAL, - k DOUBLE, - l DOUBLE PRECISION, - m FLOAT, - n NUMERIC, - o DECIMAL(10,5) + a INT, + b INTEGER, + c TINYINT, + d SMALLINT, + e MEDIUMINT, + f BIGINT, + g UNSIGNED BIG INT, + h INT2, + i INT8, + j REAL, + k DOUBLE, + l DOUBLE PRECISION, + m FLOAT, + n NUMERIC, + o DECIMAL(10,5) ); CREATE TABLE dt_numeric_not_null ( - a INT NOT NULL, - b INTEGER NOT NULL, - c TINYINT NOT NULL, - d SMALLINT NOT NULL, - e MEDIUMINT NOT NULL, - f BIGINT NOT NULL, - g UNSIGNED BIG INT NOT NULL, - h INT2 NOT NULL, - i INT8 NOT NULL, - j REAL NOT NULL, - k DOUBLE NOT NULL, - l DOUBLE PRECISION NOT NULL, - m FLOAT NOT NULL, - n NUMERIC NOT NULL, - o DECIMAL(10,5) NOT NULL + a INT NOT NULL, + b INTEGER NOT NULL, + c TINYINT NOT NULL, + d SMALLINT NOT NULL, + e MEDIUMINT NOT NULL, + f BIGINT NOT NULL, + g UNSIGNED BIG INT NOT NULL, + h INT2 NOT NULL, + i INT8 NOT NULL, + j REAL NOT NULL, + k DOUBLE NOT NULL, + l DOUBLE PRECISION NOT NULL, + m FLOAT NOT NULL, + n NUMERIC NOT NULL, + o DECIMAL(10,5) NOT NULL ); diff --git a/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/go/query.sql.go b/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/go/query.sql.go index e704e1da87..f6fb2a4b5b 100644 --- a/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/go/query.sql.go @@ -10,7 +10,7 @@ import ( ) const placeholder = `-- name: Placeholder :many -SELECT name, location, size from venues +SELECT name, location, size FROM venues ` func (q *Queries) Placeholder(ctx context.Context) ([]Venue, error) { diff --git a/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/query.sql b/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/query.sql index 1dbfac7154..c05c2203cd 100644 --- a/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/query.sql +++ b/internal/endtoend/testdata/ddl_alter_table_add_column/sqlite/query.sql @@ -1,2 +1,2 @@ /* name: Placeholder :many */ -SELECT * from venues; +SELECT * FROM venues; diff --git a/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/go/query.sql.go b/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/go/query.sql.go index 003d857f66..43e0007167 100644 --- a/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/go/query.sql.go @@ -11,7 +11,7 @@ import ( ) const insertUser = `-- name: InsertUser :exec -INSERT INTO Users (full_name, "EmailAddress", created_at) +INSERT INTO users (full_name, "EmailAddress", created_at) VALUES (?, ?, ?) ` @@ -28,7 +28,7 @@ func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) error { const selectUsers = `-- name: SelectUsers :many SELECT id, full_name, "EmailAddress", created_at -FROM Users +FROM users ` func (q *Queries) SelectUsers(ctx context.Context) ([]User, error) { diff --git a/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/query.sql b/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/query.sql index 79989697e8..d960ab1f07 100644 --- a/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/query.sql +++ b/internal/endtoend/testdata/ddl_alter_table_case_sensitivity/sqlite/query.sql @@ -1,7 +1,7 @@ -- name: InsertUser :exec -INSERT INTO Users (full_name, "EmailAddress", created_at) +INSERT INTO users (full_name, "EmailAddress", created_at) VALUES (?, ?, ?); -- name: SelectUsers :many SELECT id, full_name, "EmailAddress", created_at -FROM Users; +FROM users; diff --git a/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/go/query.sql.go b/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/go/query.sql.go index c40977d573..a0b6155ece 100644 --- a/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/go/query.sql.go @@ -10,7 +10,7 @@ import ( ) const placeholder = `-- name: Placeholder :exec -SELECT baz from foo +SELECT baz FROM foo ` func (q *Queries) Placeholder(ctx context.Context) error { diff --git a/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/query.sql b/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/query.sql index 198b08bb8d..92dc72524c 100644 --- a/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/query.sql +++ b/internal/endtoend/testdata/ddl_alter_table_drop_column/sqlite/query.sql @@ -1,2 +1,2 @@ -- name: Placeholder :exec -SELECT * from foo; +SELECT * FROM foo; diff --git a/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/go/query.sql.go b/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/go/query.sql.go index 980754a73a..e52ada4441 100644 --- a/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/go/query.sql.go @@ -11,7 +11,7 @@ import ( ) const placeholder = `-- name: Placeholder :many -SELECT name from arenas +SELECT name FROM arenas ` func (q *Queries) Placeholder(ctx context.Context) ([]sql.NullString, error) { diff --git a/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/query.sql b/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/query.sql index 3cb2745388..bf777e0cb6 100644 --- a/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/query.sql +++ b/internal/endtoend/testdata/ddl_alter_table_rename/sqlite/query.sql @@ -1,2 +1,2 @@ /* name: Placeholder :many */ -SELECT * from arenas; +SELECT * FROM arenas; diff --git a/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/go/query.sql.go b/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/go/query.sql.go index 1e373c56fa..d8317bd784 100644 --- a/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/go/query.sql.go @@ -11,7 +11,7 @@ import ( ) const placeholder = `-- name: Placeholder :many -SELECT boo from foo +SELECT boo FROM foo ` func (q *Queries) Placeholder(ctx context.Context) ([]sql.NullString, error) { diff --git a/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/query.sql b/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/query.sql index 43794d52b5..4b98a8146c 100644 --- a/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/query.sql +++ b/internal/endtoend/testdata/ddl_alter_table_rename_column/sqlite/query.sql @@ -1,2 +1,2 @@ /* name: Placeholder :many */ -SELECT * from foo; +SELECT * FROM foo; diff --git a/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/go/query.sql.go b/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/go/query.sql.go index cc56c0a7d5..d26dc4d217 100644 --- a/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/go/query.sql.go @@ -40,7 +40,8 @@ func (q *Queries) DeleteAuthor(ctx context.Context, id int64) error { } const getAuthor = `-- name: GetAuthor :one -SELECT id, name, bio FROM authors +SELECT id, name, bio +FROM authors WHERE id = ? ` @@ -52,7 +53,8 @@ func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) { } const listAuthors = `-- name: ListAuthors :many -SELECT id, name FROM authors +SELECT id, name +FROM authors ORDER BY name ` diff --git a/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/query.sql b/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/query.sql index f8efb619a7..00f0bd0746 100644 --- a/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/query.sql +++ b/internal/endtoend/testdata/experiment_coreanalyzer/sqlite/query.sql @@ -1,9 +1,11 @@ -- name: GetAuthor :one -SELECT * FROM authors +SELECT * +FROM authors WHERE id = ?; -- name: ListAuthors :many -SELECT id, name FROM authors +SELECT id, name +FROM authors ORDER BY name; -- name: CreateAuthor :one diff --git a/internal/endtoend/testdata/full_outer_join/sqlite/go/query.sql.go b/internal/endtoend/testdata/full_outer_join/sqlite/go/query.sql.go index 129a6d9118..5f514710d8 100644 --- a/internal/endtoend/testdata/full_outer_join/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/full_outer_join/sqlite/go/query.sql.go @@ -11,10 +11,11 @@ import ( ) const getAuthor = `-- name: GetAuthor :one -SELECT a.id, name, b.id, title FROM authors AS a -FULL OUTER JOIN books AS b - ON a.id = b.id -WHERE a.id = ? LIMIT 1 +SELECT a.id, name, b.id, title +FROM authors AS a +FULL JOIN books AS b ON a.id = b.id +WHERE a.id = ? +LIMIT 1 ` type GetAuthorRow struct { diff --git a/internal/endtoend/testdata/full_outer_join/sqlite/query.sql b/internal/endtoend/testdata/full_outer_join/sqlite/query.sql index b9feaba655..979d2557d3 100644 --- a/internal/endtoend/testdata/full_outer_join/sqlite/query.sql +++ b/internal/endtoend/testdata/full_outer_join/sqlite/query.sql @@ -1,5 +1,6 @@ -- name: GetAuthor :one -SELECT * FROM authors AS a -FULL OUTER JOIN books AS b - ON a.id = b.id -WHERE a.id = ? LIMIT 1; \ No newline at end of file +SELECT * +FROM authors AS a +FULL JOIN books AS b ON a.id = b.id +WHERE a.id = ? +LIMIT 1; diff --git a/internal/endtoend/testdata/func_call_cast/sqlite/go/query.sql.go b/internal/endtoend/testdata/func_call_cast/sqlite/go/query.sql.go index 6d0dbef2df..5d39885531 100644 --- a/internal/endtoend/testdata/func_call_cast/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/func_call_cast/sqlite/go/query.sql.go @@ -10,7 +10,7 @@ import ( ) const demo = `-- name: Demo :one -SELECT CAST(CHAR(1,2,3,4,5) AS BLOB) AS col1 +SELECT CAST(char(1, 2, 3, 4, 5) AS BLOB) AS col1 ` func (q *Queries) Demo(ctx context.Context) ([]byte, error) { diff --git a/internal/endtoend/testdata/func_call_cast/sqlite/query.sql b/internal/endtoend/testdata/func_call_cast/sqlite/query.sql index eb18aad656..2f27801ac5 100644 --- a/internal/endtoend/testdata/func_call_cast/sqlite/query.sql +++ b/internal/endtoend/testdata/func_call_cast/sqlite/query.sql @@ -1,2 +1,2 @@ -- name: Demo :one -SELECT CAST(CHAR(1,2,3,4,5) AS BLOB) AS col1 +SELECT CAST(char(1, 2, 3, 4, 5) AS BLOB) AS col1; diff --git a/internal/endtoend/testdata/func_match_types/sqlite/go/query.sql.go b/internal/endtoend/testdata/func_match_types/sqlite/go/query.sql.go index b6493050f0..8e56ea38b6 100644 --- a/internal/endtoend/testdata/func_match_types/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/func_match_types/sqlite/go/query.sql.go @@ -11,9 +11,9 @@ import ( ) const authorPages = `-- name: AuthorPages :many -select author, count(title) as num_books, sum(pages) as total_pages -from books -group by author +SELECT author, count(title) AS num_books, sum(pages) AS total_pages +FROM books +GROUP BY author ` type AuthorPagesRow struct { diff --git a/internal/endtoend/testdata/func_match_types/sqlite/query.sql b/internal/endtoend/testdata/func_match_types/sqlite/query.sql index 3452aebe01..fb20ace7c3 100644 --- a/internal/endtoend/testdata/func_match_types/sqlite/query.sql +++ b/internal/endtoend/testdata/func_match_types/sqlite/query.sql @@ -1,4 +1,4 @@ -- name: AuthorPages :many -select author, count(title) as num_books, sum(pages) as total_pages -from books -group by author; +SELECT author, count(title) AS num_books, sum(pages) AS total_pages +FROM books +GROUP BY author; diff --git a/internal/endtoend/testdata/inflection/sqlite/query.sql b/internal/endtoend/testdata/inflection/sqlite/query.sql index 74e1aaf8c3..26fe295aba 100644 --- a/internal/endtoend/testdata/inflection/sqlite/query.sql +++ b/internal/endtoend/testdata/inflection/sqlite/query.sql @@ -11,4 +11,4 @@ SELECT * FROM product_meta; SELECT * FROM calories; /* name: GetProductMetadata :many */ -SELECT * FROM product_metadata; \ No newline at end of file +SELECT * FROM product_metadata; diff --git a/internal/endtoend/testdata/insert_default_values/sqlite/query.sql b/internal/endtoend/testdata/insert_default_values/sqlite/query.sql index 107afbe8b5..89d593c9c0 100644 --- a/internal/endtoend/testdata/insert_default_values/sqlite/query.sql +++ b/internal/endtoend/testdata/insert_default_values/sqlite/query.sql @@ -1,2 +1,2 @@ -- name: InsertWorkspace :exec -INSERT INTO workspace DEFAULT VALUES; \ No newline at end of file +INSERT INTO workspace DEFAULT VALUES; diff --git a/internal/endtoend/testdata/insert_select/sqlite/go/query.sql.go b/internal/endtoend/testdata/insert_select/sqlite/go/query.sql.go index 7b7d191166..b158e67cff 100644 --- a/internal/endtoend/testdata/insert_select/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/insert_select/sqlite/go/query.sql.go @@ -12,7 +12,8 @@ import ( const insertSelect = `-- name: InsertSelect :exec INSERT INTO foo (name, meta) SELECT name, ? -FROM bar WHERE ready = ? +FROM bar +WHERE ready = ? ` type InsertSelectParams struct { diff --git a/internal/endtoend/testdata/insert_select/sqlite/query.sql b/internal/endtoend/testdata/insert_select/sqlite/query.sql index 880f083f9e..7707a6a32a 100644 --- a/internal/endtoend/testdata/insert_select/sqlite/query.sql +++ b/internal/endtoend/testdata/insert_select/sqlite/query.sql @@ -1,4 +1,5 @@ /* name: InsertSelect :exec */ INSERT INTO foo (name, meta) SELECT name, ? -FROM bar WHERE ready = ?; +FROM bar +WHERE ready = ?; diff --git a/internal/endtoend/testdata/insert_values/sqlite/query.sql b/internal/endtoend/testdata/insert_values/sqlite/query.sql index 774165baa8..03f37d30d9 100644 --- a/internal/endtoend/testdata/insert_values/sqlite/query.sql +++ b/internal/endtoend/testdata/insert_values/sqlite/query.sql @@ -2,4 +2,4 @@ INSERT INTO foo (a, b) VALUES (?, ?); /* name: InsertMultipleValues :exec */ -INSERT INTO foo (a, b) VALUES (?, ?), (?, ?); \ No newline at end of file +INSERT INTO foo (a, b) VALUES (?, ?), (?, ?); diff --git a/internal/endtoend/testdata/invalid_group_by_reference/sqlite/query.sql b/internal/endtoend/testdata/invalid_group_by_reference/sqlite/query.sql index b036fba240..2fc4c35be3 100644 --- a/internal/endtoend/testdata/invalid_group_by_reference/sqlite/query.sql +++ b/internal/endtoend/testdata/invalid_group_by_reference/sqlite/query.sql @@ -1,4 +1,4 @@ -- name: ListAuthors :many -SELECT * -FROM authors +SELECT * +FROM authors GROUP BY invalid_reference; diff --git a/internal/endtoend/testdata/invalid_table_alias/sqlite/query.sql b/internal/endtoend/testdata/invalid_table_alias/sqlite/query.sql index 52f5aae051..658a966e20 100644 --- a/internal/endtoend/testdata/invalid_table_alias/sqlite/query.sql +++ b/internal/endtoend/testdata/invalid_table_alias/sqlite/query.sql @@ -1,5 +1,5 @@ -- name: GetAuthor :one -SELECT * -FROM authors a -WHERE p.id = ? -LIMIT 1; +SELECT * +FROM authors AS a +WHERE p.id = ? +LIMIT 1; diff --git a/internal/endtoend/testdata/join_alias/sqlite/go/query.sql.go b/internal/endtoend/testdata/join_alias/sqlite/go/query.sql.go index 79c04bf91b..c7ef880555 100644 --- a/internal/endtoend/testdata/join_alias/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/join_alias/sqlite/go/query.sql.go @@ -12,8 +12,8 @@ import ( const aliasExpand = `-- name: AliasExpand :many SELECT f.id, b.id, title -FROM foo f -JOIN bar b ON b.id = f.id +FROM foo AS f +JOIN bar AS b ON b.id = f.id WHERE f.id = ? ` @@ -48,8 +48,8 @@ func (q *Queries) AliasExpand(ctx context.Context, id int64) ([]AliasExpandRow, const aliasJoin = `-- name: AliasJoin :many SELECT f.id, b.title -FROM foo f -JOIN bar b ON b.id = f.id +FROM foo AS f +JOIN bar AS b ON b.id = f.id WHERE f.id = ? ` diff --git a/internal/endtoend/testdata/join_alias/sqlite/query.sql b/internal/endtoend/testdata/join_alias/sqlite/query.sql index 9b087bcae7..cfb69f01dd 100644 --- a/internal/endtoend/testdata/join_alias/sqlite/query.sql +++ b/internal/endtoend/testdata/join_alias/sqlite/query.sql @@ -1,11 +1,11 @@ -- name: AliasJoin :many SELECT f.id, b.title -FROM foo f -JOIN bar b ON b.id = f.id +FROM foo AS f +JOIN bar AS b ON b.id = f.id WHERE f.id = ?; -- name: AliasExpand :many SELECT * -FROM foo f -JOIN bar b ON b.id = f.id +FROM foo AS f +JOIN bar AS b ON b.id = f.id WHERE f.id = ?; diff --git a/internal/endtoend/testdata/join_left/sqlite/go/query.sql.go b/internal/endtoend/testdata/join_left/sqlite/go/query.sql.go index e3c0ff7d8f..4037bc4718 100644 --- a/internal/endtoend/testdata/join_left/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/join_left/sqlite/go/query.sql.go @@ -12,10 +12,9 @@ import ( ) const allAuthors = `-- name: AllAuthors :many -SELECT a.id, a.name, a.parent_id, p.id, p.name, p.parent_id -FROM authors AS a - LEFT JOIN authors AS p - ON a.parent_id = p.id +SELECT a.id, a.name, a.parent_id, p.id, p.name, p.parent_id +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id ` type AllAuthorsRow struct { @@ -58,10 +57,9 @@ func (q *Queries) AllAuthors(ctx context.Context) ([]AllAuthorsRow, error) { } const allAuthorsAliases = `-- name: AllAuthorsAliases :many -SELECT a.id, a.name, a.parent_id, p.id, p.name, p.parent_id -FROM authors AS a - LEFT JOIN authors AS p - ON a.parent_id = p.id +SELECT a.id, a.name, a.parent_id, p.id, p.name, p.parent_id +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id ` type AllAuthorsAliasesRow struct { @@ -104,10 +102,9 @@ func (q *Queries) AllAuthorsAliases(ctx context.Context) ([]AllAuthorsAliasesRow } const allAuthorsAliases2 = `-- name: AllAuthorsAliases2 :many -SELECT a.id, a.name, a.parent_id, p.id, p.name, p.parent_id -FROM authors AS a - LEFT JOIN authors AS p - ON a.parent_id = p.id +SELECT a.id, a.name, a.parent_id, p.id, p.name, p.parent_id +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id ` type AllAuthorsAliases2Row struct { @@ -150,10 +147,9 @@ func (q *Queries) AllAuthorsAliases2(ctx context.Context) ([]AllAuthorsAliases2R } const allSuperAuthors = `-- name: AllSuperAuthors :many -SELECT id, name, parent_id, super_id, super_name, super_parent_id -FROM authors - LEFT JOIN super_authors - ON authors.parent_id = super_authors.super_id +SELECT id, name, parent_id, super_id, super_name, super_parent_id +FROM authors +LEFT JOIN super_authors ON authors.parent_id = super_authors.super_id ` type AllSuperAuthorsRow struct { @@ -196,10 +192,9 @@ func (q *Queries) AllSuperAuthors(ctx context.Context) ([]AllSuperAuthorsRow, er } const allSuperAuthorsAliases = `-- name: AllSuperAuthorsAliases :many -SELECT id, name, parent_id, super_id, super_name, super_parent_id -FROM authors AS a - LEFT JOIN super_authors AS sa - ON a.parent_id = sa.super_id +SELECT id, name, parent_id, super_id, super_name, super_parent_id +FROM authors AS a +LEFT JOIN super_authors AS sa ON a.parent_id = sa.super_id ` type AllSuperAuthorsAliasesRow struct { @@ -242,10 +237,9 @@ func (q *Queries) AllSuperAuthorsAliases(ctx context.Context) ([]AllSuperAuthors } const allSuperAuthorsAliases2 = `-- name: AllSuperAuthorsAliases2 :many -SELECT a.id, a.name, a.parent_id, sa.super_id, sa.super_name, sa.super_parent_id -FROM authors AS a - LEFT JOIN super_authors AS sa - ON a.parent_id = sa.super_id +SELECT a.id, a.name, a.parent_id, sa.super_id, sa.super_name, sa.super_parent_id +FROM authors AS a +LEFT JOIN super_authors AS sa ON a.parent_id = sa.super_id ` type AllSuperAuthorsAliases2Row struct { @@ -289,11 +283,11 @@ func (q *Queries) AllSuperAuthorsAliases2(ctx context.Context) ([]AllSuperAuthor const getMayors = `-- name: GetMayors :many SELECT - user_id, - mayors.full_name + user_id, + mayors.full_name FROM users LEFT JOIN cities USING (city_id) -INNER JOIN mayors USING (mayor_id) +JOIN mayors USING (mayor_id) ` type GetMayorsRow struct { @@ -326,9 +320,9 @@ func (q *Queries) GetMayors(ctx context.Context) ([]GetMayorsRow, error) { const getMayorsOptional = `-- name: GetMayorsOptional :many SELECT - user_id, - cities.city_id, - mayors.full_name + user_id, + cities.city_id, + mayors.full_name FROM users LEFT JOIN cities USING (city_id) LEFT JOIN mayors USING (mayor_id) @@ -364,11 +358,10 @@ func (q *Queries) GetMayorsOptional(ctx context.Context) ([]GetMayorsOptionalRow } const getSuggestedUsersByID = `-- name: GetSuggestedUsersByID :many -SELECT DISTINCT u.user_id, u.user_nickname, u.user_email, u.user_display_name, u.user_password, u.user_google_id, u.user_apple_id, u.user_bio, u.user_created_at, u.user_avatar_id, m.media_id, m.media_created_at, m.media_hash, m.media_directory, m.media_author_id, m.media_width, m.media_height -FROM users_2 AS u - LEFT JOIN media AS m - ON u.user_avatar_id = m.media_id -WHERE u.user_id != ?1 +SELECT DISTINCT u.user_id, u.user_nickname, u.user_email, u.user_display_name, u.user_password, u.user_google_id, u.user_apple_id, u.user_bio, u.user_created_at, u.user_avatar_id, m.media_id, m.media_created_at, m.media_hash, m.media_directory, m.media_author_id, m.media_width, m.media_height +FROM users_2 AS u +LEFT JOIN media AS m ON u.user_avatar_id = m.media_id +WHERE u.user_id != ?1 ` type GetSuggestedUsersByIDRow struct { @@ -433,11 +426,10 @@ func (q *Queries) GetSuggestedUsersByID(ctx context.Context, userID int64) ([]Ge } const getSuggestedUsersByID2 = `-- name: GetSuggestedUsersByID2 :many -SELECT users_2.user_id -FROM users_2 - LEFT JOIN media AS m - ON user_avatar_id = m.media_id -WHERE user_id != ?1 +SELECT users_2.user_id +FROM users_2 +LEFT JOIN media AS m ON user_avatar_id = m.media_id +WHERE user_id != ?1 ` func (q *Queries) GetSuggestedUsersByID2(ctx context.Context, userID int64) ([]int64, error) { diff --git a/internal/endtoend/testdata/join_left/sqlite/query.sql b/internal/endtoend/testdata/join_left/sqlite/query.sql index d9ccaede83..863f0d294d 100644 --- a/internal/endtoend/testdata/join_left/sqlite/query.sql +++ b/internal/endtoend/testdata/join_left/sqlite/query.sql @@ -1,66 +1,58 @@ -- name: GetMayors :many SELECT - user_id, - mayors.full_name + user_id, + mayors.full_name FROM users LEFT JOIN cities USING (city_id) -INNER JOIN mayors USING (mayor_id); +JOIN mayors USING (mayor_id); -- name: GetMayorsOptional :many SELECT - user_id, - cities.city_id, - mayors.full_name + user_id, + cities.city_id, + mayors.full_name FROM users LEFT JOIN cities USING (city_id) LEFT JOIN mayors USING (mayor_id); -- name: AllAuthors :many -SELECT * -FROM authors AS a - LEFT JOIN authors AS p - ON a.parent_id = p.id; +SELECT * +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id; -- name: AllAuthorsAliases :many -SELECT * -FROM authors AS a - LEFT JOIN authors AS p - ON a.parent_id = p.id; +SELECT * +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id; -- name: AllSuperAuthors :many -SELECT * -FROM authors - LEFT JOIN super_authors - ON authors.parent_id = super_authors.super_id; +SELECT * +FROM authors +LEFT JOIN super_authors ON authors.parent_id = super_authors.super_id; -- name: AllAuthorsAliases2 :many -SELECT a.*, p.* -FROM authors AS a - LEFT JOIN authors AS p - ON a.parent_id = p.id; +SELECT a.*, p.* +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id; -- name: AllSuperAuthorsAliases :many -SELECT * -FROM authors AS a - LEFT JOIN super_authors AS sa - ON a.parent_id = sa.super_id; +SELECT * +FROM authors AS a +LEFT JOIN super_authors AS sa ON a.parent_id = sa.super_id; -- name: AllSuperAuthorsAliases2 :many -SELECT a.*, sa.* -FROM authors AS a - LEFT JOIN super_authors AS sa - ON a.parent_id = sa.super_id; +SELECT a.*, sa.* +FROM authors AS a +LEFT JOIN super_authors AS sa ON a.parent_id = sa.super_id; -- name: GetSuggestedUsersByID :many -SELECT DISTINCT u.*, m.* -FROM users_2 AS u - LEFT JOIN media AS m - ON u.user_avatar_id = m.media_id -WHERE u.user_id != @user_id; +SELECT DISTINCT u.*, m.* +FROM users_2 AS u +LEFT JOIN media AS m ON u.user_avatar_id = m.media_id +WHERE u.user_id != @user_id; -- name: GetSuggestedUsersByID2 :many -SELECT users_2.user_id -FROM users_2 - LEFT JOIN media AS m - ON user_avatar_id = m.media_id -WHERE user_id != @user_id; +SELECT users_2.user_id +FROM users_2 +LEFT JOIN media AS m ON user_avatar_id = m.media_id +WHERE user_id != @user_id; diff --git a/internal/endtoend/testdata/join_left_same_table/sqlite/go/query.sql.go b/internal/endtoend/testdata/join_left_same_table/sqlite/go/query.sql.go index 2caf8e4aea..1e566df2da 100644 --- a/internal/endtoend/testdata/join_left_same_table/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/join_left_same_table/sqlite/go/query.sql.go @@ -11,13 +11,13 @@ import ( ) const allAuthors = `-- name: AllAuthors :many -SELECT a.id, - a.name, - p.id as alias_id, - p.name as alias_name -FROM authors AS a - LEFT JOIN authors AS p - ON (a.parent_id = p.id) +SELECT + a.id, + a.name, + p.id AS alias_id, + p.name AS alias_name +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id ` type AllAuthorsRow struct { diff --git a/internal/endtoend/testdata/join_left_same_table/sqlite/query.sql b/internal/endtoend/testdata/join_left_same_table/sqlite/query.sql index 79daa2dfd5..6430a52086 100644 --- a/internal/endtoend/testdata/join_left_same_table/sqlite/query.sql +++ b/internal/endtoend/testdata/join_left_same_table/sqlite/query.sql @@ -1,8 +1,8 @@ -- name: AllAuthors :many -SELECT a.id, - a.name, - p.id as alias_id, - p.name as alias_name -FROM authors AS a - LEFT JOIN authors AS p - ON (a.parent_id = p.id); +SELECT + a.id, + a.name, + p.id AS alias_id, + p.name AS alias_name +FROM authors AS a +LEFT JOIN authors AS p ON a.parent_id = p.id; diff --git a/internal/endtoend/testdata/join_where_clause/sqlite/query.sql b/internal/endtoend/testdata/join_where_clause/sqlite/query.sql index 2b5ae53b00..bdff39a5ba 100644 --- a/internal/endtoend/testdata/join_where_clause/sqlite/query.sql +++ b/internal/endtoend/testdata/join_where_clause/sqlite/query.sql @@ -14,4 +14,4 @@ WHERE owner = ?; SELECT foo.* FROM foo CROSS JOIN bar -WHERE bar.id = ? AND owner = ?; \ No newline at end of file +WHERE bar.id = ? AND owner = ?; diff --git a/internal/endtoend/testdata/jsonb/sqlite/go/query.sql.go b/internal/endtoend/testdata/jsonb/sqlite/go/query.sql.go index a864448e87..655f57af7f 100644 --- a/internal/endtoend/testdata/jsonb/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/jsonb/sqlite/go/query.sql.go @@ -12,24 +12,26 @@ import ( const insertFoo = `-- name: InsertFoo :exec INSERT INTO foo ( - a, - b, - c, - d, - e, - f, - g, - h -) VALUES ( - ?1, - ?2, - ?3, - ?4, - ?5, - ?6, - ?7, - ?8 -) RETURNING a, json(b), c, json(d), e, json(f), g, json(h) + a, + b, + c, + d, + e, + f, + g, + h +) +VALUES ( + ?1, + ?2, + ?3, + ?4, + ?5, + ?6, + ?7, + ?8 +) +RETURNING a, json(b), c, json(d), e, json(f), g, json(h) ` type InsertFooParams struct { diff --git a/internal/endtoend/testdata/jsonb/sqlite/query.sql b/internal/endtoend/testdata/jsonb/sqlite/query.sql index baca24c120..0fe40ee2e2 100644 --- a/internal/endtoend/testdata/jsonb/sqlite/query.sql +++ b/internal/endtoend/testdata/jsonb/sqlite/query.sql @@ -1,23 +1,25 @@ -- name: InsertFoo :exec INSERT INTO foo ( - a, - b, - c, - d, - e, - f, - g, - h -) VALUES ( - @a, - @b, - @c, - @d, - @e, - @f, - @g, - @h -) RETURNING *; + a, + b, + c, + d, + e, + f, + g, + h +) +VALUES ( + @a, + @b, + @c, + @d, + @e, + @f, + @g, + @h +) +RETURNING *; -- name: SelectFoo :exec SELECT * FROM foo; diff --git a/internal/endtoend/testdata/multibyte_comment/sqlite/go/query.sql.go b/internal/endtoend/testdata/multibyte_comment/sqlite/go/query.sql.go index af8e925bb7..0ff9f72028 100644 --- a/internal/endtoend/testdata/multibyte_comment/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/multibyte_comment/sqlite/go/query.sql.go @@ -39,7 +39,9 @@ func (q *Queries) DeleteItem(ctx context.Context, id int64) (Item, error) { const listItems = `-- name: ListItems :many SELECT id, name, cap_read -FROM items WHERE cap_read = 'anonymous' ORDER BY name +FROM items +WHERE cap_read = 'anonymous' +ORDER BY name ` // Multi-byte UTF-8 in comments must not shift the byte offsets used to slice diff --git a/internal/endtoend/testdata/multibyte_comment/sqlite/query.sql b/internal/endtoend/testdata/multibyte_comment/sqlite/query.sql index 6a191d9b57..527d3900ca 100644 --- a/internal/endtoend/testdata/multibyte_comment/sqlite/query.sql +++ b/internal/endtoend/testdata/multibyte_comment/sqlite/query.sql @@ -4,7 +4,9 @@ -- name: ListItems :many -- an em dash right here — must not truncate the ORDER BY below SELECT id, name, cap_read -FROM items WHERE cap_read = 'anonymous' ORDER BY name; +FROM items +WHERE cap_read = 'anonymous' +ORDER BY name; -- section — divider between queries diff --git a/internal/endtoend/testdata/quoted_colname/sqlite/go/query.sql.go b/internal/endtoend/testdata/quoted_colname/sqlite/go/query.sql.go index cef85ab2ab..1e5ad1ed36 100644 --- a/internal/endtoend/testdata/quoted_colname/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/quoted_colname/sqlite/go/query.sql.go @@ -10,7 +10,7 @@ import ( ) const testList = `-- name: TestList :many -SELECT id FROM "test" +SELECT id FROM test ` func (q *Queries) TestList(ctx context.Context) ([]string, error) { diff --git a/internal/endtoend/testdata/quoted_colname/sqlite/query.sql b/internal/endtoend/testdata/quoted_colname/sqlite/query.sql index 8b8ae15e9a..10a35f0464 100644 --- a/internal/endtoend/testdata/quoted_colname/sqlite/query.sql +++ b/internal/endtoend/testdata/quoted_colname/sqlite/query.sql @@ -1,2 +1,2 @@ -- name: TestList :many -SELECT * FROM "test"; \ No newline at end of file +SELECT * FROM test; diff --git a/internal/endtoend/testdata/returning/sqlite/go/query.sql.go b/internal/endtoend/testdata/returning/sqlite/go/query.sql.go index 258aedc44d..c081f1c29f 100644 --- a/internal/endtoend/testdata/returning/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/returning/sqlite/go/query.sql.go @@ -12,8 +12,8 @@ import ( const deleteUserAndReturnID = `-- name: DeleteUserAndReturnID :one DELETE FROM users - WHERE name = ?1 - RETURNING id +WHERE name = ?1 +RETURNING id ` func (q *Queries) DeleteUserAndReturnID(ctx context.Context, name sql.NullString) (int64, error) { @@ -25,8 +25,8 @@ func (q *Queries) DeleteUserAndReturnID(ctx context.Context, name sql.NullString const deleteUserAndReturnUser = `-- name: DeleteUserAndReturnUser :one DELETE FROM users - WHERE name = ?1 - RETURNING name, id +WHERE name = ?1 +RETURNING name, id ` func (q *Queries) DeleteUserAndReturnUser(ctx context.Context, name sql.NullString) (User, error) { @@ -37,8 +37,9 @@ func (q *Queries) DeleteUserAndReturnUser(ctx context.Context, name sql.NullStri } const insertUserAndReturnID = `-- name: InsertUserAndReturnID :one -INSERT INTO users (name) VALUES (?1) - RETURNING id +INSERT INTO users (name) +VALUES (?1) +RETURNING id ` func (q *Queries) InsertUserAndReturnID(ctx context.Context, name sql.NullString) (int64, error) { @@ -49,8 +50,9 @@ func (q *Queries) InsertUserAndReturnID(ctx context.Context, name sql.NullString } const insertUserAndReturnUser = `-- name: InsertUserAndReturnUser :one -INSERT INTO users (name) VALUES (?1) - RETURNING name, id +INSERT INTO users (name) +VALUES (?1) +RETURNING name, id ` func (q *Queries) InsertUserAndReturnUser(ctx context.Context, name sql.NullString) (User, error) { @@ -61,9 +63,10 @@ func (q *Queries) InsertUserAndReturnUser(ctx context.Context, name sql.NullStri } const updateUserAndReturnID = `-- name: UpdateUserAndReturnID :one -UPDATE users SET name = ?1 - WHERE name = ?2 - RETURNING id +UPDATE users +SET name = ?1 +WHERE name = ?2 +RETURNING id ` type UpdateUserAndReturnIDParams struct { @@ -79,9 +82,10 @@ func (q *Queries) UpdateUserAndReturnID(ctx context.Context, arg UpdateUserAndRe } const updateUserAndReturnUser = `-- name: UpdateUserAndReturnUser :one -UPDATE users SET name = ?1 - WHERE name = ?2 - RETURNING name, id +UPDATE users +SET name = ?1 +WHERE name = ?2 +RETURNING name, id ` type UpdateUserAndReturnUserParams struct { diff --git a/internal/endtoend/testdata/returning/sqlite/query.sql b/internal/endtoend/testdata/returning/sqlite/query.sql index ded7c9e810..974f37e3bf 100644 --- a/internal/endtoend/testdata/returning/sqlite/query.sql +++ b/internal/endtoend/testdata/returning/sqlite/query.sql @@ -1,27 +1,31 @@ -- name: InsertUserAndReturnID :one -INSERT INTO users (name) VALUES (?1) - RETURNING id; +INSERT INTO users (name) +VALUES (?1) +RETURNING id; -- name: InsertUserAndReturnUser :one -INSERT INTO users (name) VALUES (?1) - RETURNING *; +INSERT INTO users (name) +VALUES (?1) +RETURNING *; -- name: UpdateUserAndReturnID :one -UPDATE users SET name = ?1 - WHERE name = ?2 - RETURNING id; +UPDATE users +SET name = ?1 +WHERE name = ?2 +RETURNING id; -- name: UpdateUserAndReturnUser :one -UPDATE users SET name = ?1 - WHERE name = ?2 - RETURNING *; +UPDATE users +SET name = ?1 +WHERE name = ?2 +RETURNING *; -- name: DeleteUserAndReturnID :one DELETE FROM users - WHERE name = ?1 - RETURNING id; +WHERE name = ?1 +RETURNING id; -- name: DeleteUserAndReturnUser :one DELETE FROM users - WHERE name = ?1 - RETURNING *; +WHERE name = ?1 +RETURNING *; diff --git a/internal/endtoend/testdata/select_exists/sqlite/go/query.sql.go b/internal/endtoend/testdata/select_exists/sqlite/go/query.sql.go index 8af010d08c..d0d680408d 100644 --- a/internal/endtoend/testdata/select_exists/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/select_exists/sqlite/go/query.sql.go @@ -11,14 +11,11 @@ import ( const barExists = `-- name: BarExists :one SELECT - EXISTS ( - SELECT - 1 - FROM - bar - where - id = ? - ) + EXISTS ( + SELECT 1 + FROM bar + WHERE id = ? + ) ` func (q *Queries) BarExists(ctx context.Context, id int64) (bool, error) { diff --git a/internal/endtoend/testdata/select_exists/sqlite/query.sql b/internal/endtoend/testdata/select_exists/sqlite/query.sql index 5173a4418f..15ef7be358 100644 --- a/internal/endtoend/testdata/select_exists/sqlite/query.sql +++ b/internal/endtoend/testdata/select_exists/sqlite/query.sql @@ -1,10 +1,7 @@ -- name: BarExists :one SELECT - EXISTS ( - SELECT - 1 - FROM - bar - where - id = ? - ); + EXISTS ( + SELECT 1 + FROM bar + WHERE id = ? + ); diff --git a/internal/endtoend/testdata/select_in_and/sqlite/go/query.sql.go b/internal/endtoend/testdata/select_in_and/sqlite/go/query.sql.go index 11694d1671..3a97dad1de 100644 --- a/internal/endtoend/testdata/select_in_and/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/select_in_and/sqlite/go/query.sql.go @@ -11,24 +11,16 @@ import ( ) const deleteAuthor = `-- name: DeleteAuthor :exec -DELETE FROM - books AS b -WHERE - b.author NOT IN ( - SELECT - a.name - FROM - authors a - WHERE - a.age >= ? +DELETE FROM books AS b +WHERE NOT b.author IN ( + SELECT a.name + FROM authors AS a + WHERE a.age >= ? ) - AND b.translator NOT IN ( - SELECT - t.name - FROM - translators t - WHERE - t.age >= ? + AND NOT b.translator IN ( + SELECT t.name + FROM translators AS t + WHERE t.age >= ? ) AND b.year <= ? ` diff --git a/internal/endtoend/testdata/select_in_and/sqlite/query.sql b/internal/endtoend/testdata/select_in_and/sqlite/query.sql index 4bad135e3d..a4e760f508 100644 --- a/internal/endtoend/testdata/select_in_and/sqlite/query.sql +++ b/internal/endtoend/testdata/select_in_and/sqlite/query.sql @@ -1,21 +1,13 @@ -- name: DeleteAuthor :exec -DELETE FROM - books AS b -WHERE - b.author NOT IN ( - SELECT - a.name - FROM - authors a - WHERE - a.age >= ? +DELETE FROM books AS b +WHERE NOT b.author IN ( + SELECT a.name + FROM authors AS a + WHERE a.age >= ? ) - AND b.translator NOT IN ( - SELECT - t.name - FROM - translators t - WHERE - t.age >= ? + AND NOT b.translator IN ( + SELECT t.name + FROM translators AS t + WHERE t.age >= ? ) - AND b.year <= ?; \ No newline at end of file + AND b.year <= ?; diff --git a/internal/endtoend/testdata/select_limit/sqlite/go/query.sql.go b/internal/endtoend/testdata/select_limit/sqlite/go/query.sql.go index 029c3950df..8eba03c574 100644 --- a/internal/endtoend/testdata/select_limit/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/select_limit/sqlite/go/query.sql.go @@ -11,7 +11,8 @@ import ( ) const fooLimit = `-- name: FooLimit :many -SELECT a FROM foo +SELECT a +FROM foo LIMIT ? ` @@ -39,8 +40,10 @@ func (q *Queries) FooLimit(ctx context.Context, limit int64) ([]sql.NullString, } const fooLimitOffset = `-- name: FooLimitOffset :many -SELECT a FROM foo -LIMIT ? OFFSET ? +SELECT a +FROM foo +LIMIT ? +OFFSET ? ` type FooLimitOffsetParams struct { diff --git a/internal/endtoend/testdata/select_limit/sqlite/query.sql b/internal/endtoend/testdata/select_limit/sqlite/query.sql index 1fea17c583..c2e9c39c83 100644 --- a/internal/endtoend/testdata/select_limit/sqlite/query.sql +++ b/internal/endtoend/testdata/select_limit/sqlite/query.sql @@ -1,7 +1,10 @@ /* name: FooLimit :many */ -SELECT a FROM foo +SELECT a +FROM foo LIMIT ?; /* name: FooLimitOffset :many */ -SELECT a FROM foo -LIMIT ? OFFSET ?; +SELECT a +FROM foo +LIMIT ? +OFFSET ?; diff --git a/internal/endtoend/testdata/select_nested_count/sqlite/go/query.sql.go b/internal/endtoend/testdata/select_nested_count/sqlite/go/query.sql.go index ca978554b3..0b610a9c83 100644 --- a/internal/endtoend/testdata/select_nested_count/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/select_nested_count/sqlite/go/query.sql.go @@ -11,10 +11,13 @@ import ( ) const getAuthorsWithBooksCount = `-- name: GetAuthorsWithBooksCount :many -SELECT id, name, bio, ( - SELECT COUNT(id) FROM books - WHERE books.author_id = id -) AS books_count +SELECT + id, name, bio, + ( + SELECT count(id) + FROM books + WHERE books.author_id = id + ) AS books_count FROM authors ` diff --git a/internal/endtoend/testdata/select_nested_count/sqlite/query.sql b/internal/endtoend/testdata/select_nested_count/sqlite/query.sql index 3fe51959c3..90069960a4 100644 --- a/internal/endtoend/testdata/select_nested_count/sqlite/query.sql +++ b/internal/endtoend/testdata/select_nested_count/sqlite/query.sql @@ -1,6 +1,9 @@ -- name: GetAuthorsWithBooksCount :many -SELECT *, ( - SELECT COUNT(id) FROM books - WHERE books.author_id = id -) AS books_count +SELECT + *, + ( + SELECT count(id) + FROM books + WHERE books.author_id = id + ) AS books_count FROM authors; diff --git a/internal/endtoend/testdata/select_not_exists/sqlite/go/query.sql.go b/internal/endtoend/testdata/select_not_exists/sqlite/go/query.sql.go index e62a636a67..dfa8dcedcc 100644 --- a/internal/endtoend/testdata/select_not_exists/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/select_not_exists/sqlite/go/query.sql.go @@ -11,14 +11,11 @@ import ( const barNotExists = `-- name: BarNotExists :one SELECT - NOT EXISTS ( - SELECT - 1 - FROM - bar - WHERE - id = ? - ) + NOT EXISTS ( + SELECT 1 + FROM bar + WHERE id = ? + ) ` func (q *Queries) BarNotExists(ctx context.Context, id int64) (bool, error) { diff --git a/internal/endtoend/testdata/select_not_exists/sqlite/query.sql b/internal/endtoend/testdata/select_not_exists/sqlite/query.sql index f7e76ae92c..f5dab6a174 100644 --- a/internal/endtoend/testdata/select_not_exists/sqlite/query.sql +++ b/internal/endtoend/testdata/select_not_exists/sqlite/query.sql @@ -1,11 +1,7 @@ -- name: BarNotExists :one SELECT - NOT EXISTS ( - SELECT - 1 - FROM - bar - WHERE - id = ? - ); - + NOT EXISTS ( + SELECT 1 + FROM bar + WHERE id = ? + ); diff --git a/internal/endtoend/testdata/select_star/sqlite/go/query.sql.go b/internal/endtoend/testdata/select_star/sqlite/go/query.sql.go index 03e2902046..e9e6c25fe5 100644 --- a/internal/endtoend/testdata/select_star/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/select_star/sqlite/go/query.sql.go @@ -42,7 +42,7 @@ func (q *Queries) GetAll(ctx context.Context) ([]User, error) { } const getIDAll = `-- name: GetIDAll :many -SELECT id FROM (SELECT id FROM users) t +SELECT id FROM (SELECT id FROM users) AS t ` func (q *Queries) GetIDAll(ctx context.Context) ([]int64, error) { diff --git a/internal/endtoend/testdata/select_star/sqlite/query.sql b/internal/endtoend/testdata/select_star/sqlite/query.sql index 0952880cac..ba7ed34469 100644 --- a/internal/endtoend/testdata/select_star/sqlite/query.sql +++ b/internal/endtoend/testdata/select_star/sqlite/query.sql @@ -2,4 +2,4 @@ SELECT * FROM users; /* name: GetIDAll :many */ -SELECT * FROM (SELECT id FROM users) t; \ No newline at end of file +SELECT * FROM (SELECT id FROM users) AS t; diff --git a/internal/endtoend/testdata/select_union/sqlite/go/query.sql.go b/internal/endtoend/testdata/select_union/sqlite/go/query.sql.go index 576e74720e..42d9cde73d 100644 --- a/internal/endtoend/testdata/select_union/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/select_union/sqlite/go/query.sql.go @@ -129,7 +129,8 @@ const selectUnionWithLimit = `-- name: SelectUnionWithLimit :many SELECT a, b FROM foo UNION SELECT a, b FROM foo -LIMIT ? OFFSET ? +LIMIT ? +OFFSET ? ` type SelectUnionWithLimitParams struct { diff --git a/internal/endtoend/testdata/select_union/sqlite/query.sql b/internal/endtoend/testdata/select_union/sqlite/query.sql index 67d28d1824..1880a56d21 100644 --- a/internal/endtoend/testdata/select_union/sqlite/query.sql +++ b/internal/endtoend/testdata/select_union/sqlite/query.sql @@ -7,7 +7,8 @@ SELECT * FROM foo; SELECT * FROM foo UNION SELECT * FROM foo -LIMIT ? OFFSET ?; +LIMIT ? +OFFSET ?; -- name: SelectExcept :many SELECT * FROM foo diff --git a/internal/endtoend/testdata/single_param_conflict/sqlite/go/query.sql.go b/internal/endtoend/testdata/single_param_conflict/sqlite/go/query.sql.go index 71681b3ba8..0499ffb86d 100644 --- a/internal/endtoend/testdata/single_param_conflict/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/single_param_conflict/sqlite/go/query.sql.go @@ -10,10 +10,10 @@ import ( ) const getAuthorByID = `-- name: GetAuthorByID :one -SELECT id, name, bio -FROM authors -WHERE id = ? -LIMIT 1 +SELECT id, name, bio +FROM authors +WHERE id = ? +LIMIT 1 ` func (q *Queries) GetAuthorByID(ctx context.Context, id int64) (Author, error) { @@ -24,10 +24,10 @@ func (q *Queries) GetAuthorByID(ctx context.Context, id int64) (Author, error) { } const getAuthorIDByID = `-- name: GetAuthorIDByID :one -SELECT id -FROM authors -WHERE id = ? -LIMIT 1 +SELECT id +FROM authors +WHERE id = ? +LIMIT 1 ` func (q *Queries) GetAuthorIDByID(ctx context.Context, id int64) (int64, error) { @@ -38,10 +38,10 @@ func (q *Queries) GetAuthorIDByID(ctx context.Context, id int64) (int64, error) } const getUser = `-- name: GetUser :one -SELECT sub -FROM users -WHERE sub = ? -LIMIT 1 +SELECT sub +FROM users +WHERE sub = ? +LIMIT 1 ` func (q *Queries) GetUser(ctx context.Context, sub string) (string, error) { diff --git a/internal/endtoend/testdata/single_param_conflict/sqlite/query.sql b/internal/endtoend/testdata/single_param_conflict/sqlite/query.sql index 23b454dac0..504f77945f 100644 --- a/internal/endtoend/testdata/single_param_conflict/sqlite/query.sql +++ b/internal/endtoend/testdata/single_param_conflict/sqlite/query.sql @@ -1,17 +1,17 @@ -- name: GetAuthorIDByID :one -SELECT id -FROM authors -WHERE id = ? -LIMIT 1; +SELECT id +FROM authors +WHERE id = ? +LIMIT 1; -- name: GetAuthorByID :one -SELECT id, name, bio -FROM authors -WHERE id = ? -LIMIT 1; +SELECT id, name, bio +FROM authors +WHERE id = ? +LIMIT 1; -- name: GetUser :one -SELECT sub -FROM users -WHERE sub = ? -LIMIT 1; +SELECT sub +FROM users +WHERE sub = ? +LIMIT 1; diff --git a/internal/endtoend/testdata/sqlite_skip_todo/db/query.sql.go b/internal/endtoend/testdata/sqlite_skip_todo/db/query.sql.go index 97feda59d0..27211722b5 100644 --- a/internal/endtoend/testdata/sqlite_skip_todo/db/query.sql.go +++ b/internal/endtoend/testdata/sqlite_skip_todo/db/query.sql.go @@ -11,7 +11,8 @@ import ( ) const getFoo = `-- name: GetFoo :many -SELECT bar FROM foo +SELECT bar +FROM foo WHERE bar = ? ` diff --git a/internal/endtoend/testdata/sqlite_skip_todo/query.sql b/internal/endtoend/testdata/sqlite_skip_todo/query.sql index e51c45c8c1..5e055229fa 100644 --- a/internal/endtoend/testdata/sqlite_skip_todo/query.sql +++ b/internal/endtoend/testdata/sqlite_skip_todo/query.sql @@ -11,6 +11,6 @@ PRAGMA foreign_keys = 0; PRAGMA foreign_keys; -- name: GetFoo :many -SELECT * FROM foo +SELECT * +FROM foo WHERE bar = ?; - diff --git a/internal/endtoend/testdata/sqlite_table_options/sqlite/go/query.sql.go b/internal/endtoend/testdata/sqlite_table_options/sqlite/go/query.sql.go index d563ef827e..6f1e81df90 100644 --- a/internal/endtoend/testdata/sqlite_table_options/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/sqlite_table_options/sqlite/go/query.sql.go @@ -10,8 +10,10 @@ import ( ) const getAuthor = `-- name: GetAuthor :one -SELECT id, name, bio FROM authors1 -WHERE id = ?1 LIMIT 1 +SELECT id, name, bio +FROM authors1 +WHERE id = ?1 +LIMIT 1 ` func (q *Queries) GetAuthor(ctx context.Context, id int64) (Authors1, error) { diff --git a/internal/endtoend/testdata/sqlite_table_options/sqlite/query.sql b/internal/endtoend/testdata/sqlite_table_options/sqlite/query.sql index 749f91601d..2fe76dc099 100644 --- a/internal/endtoend/testdata/sqlite_table_options/sqlite/query.sql +++ b/internal/endtoend/testdata/sqlite_table_options/sqlite/query.sql @@ -1,3 +1,5 @@ -- name: GetAuthor :one -SELECT * FROM authors1 -WHERE id = ?1 LIMIT 1; +SELECT * +FROM authors1 +WHERE id = ?1 +LIMIT 1; diff --git a/internal/endtoend/testdata/star_expansion/sqlite/go/query.sql.go b/internal/endtoend/testdata/star_expansion/sqlite/go/query.sql.go index b56411ca25..47308250ae 100644 --- a/internal/endtoend/testdata/star_expansion/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/star_expansion/sqlite/go/query.sql.go @@ -54,7 +54,7 @@ func (q *Queries) StarExpansion(ctx context.Context) ([]StarExpansionRow, error) } const starQuotedExpansion = `-- name: StarQuotedExpansion :many -SELECT t.a, t.b FROM foo "t" +SELECT t.a, t.b FROM foo AS t ` func (q *Queries) StarQuotedExpansion(ctx context.Context) ([]Foo, error) { diff --git a/internal/endtoend/testdata/star_expansion/sqlite/query.sql b/internal/endtoend/testdata/star_expansion/sqlite/query.sql index 6249bb48b7..1afa2b3996 100644 --- a/internal/endtoend/testdata/star_expansion/sqlite/query.sql +++ b/internal/endtoend/testdata/star_expansion/sqlite/query.sql @@ -2,4 +2,4 @@ SELECT *, *, foo.* FROM foo; -- name: StarQuotedExpansion :many -SELECT "t".* FROM foo "t"; +SELECT t.* FROM foo AS t; diff --git a/internal/endtoend/testdata/star_expansion_core/sqlite/go/query.sql.go b/internal/endtoend/testdata/star_expansion_core/sqlite/go/query.sql.go index 52a39ab75c..4ed292f831 100644 --- a/internal/endtoend/testdata/star_expansion_core/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/star_expansion_core/sqlite/go/query.sql.go @@ -225,7 +225,7 @@ func (q *Queries) StarExpansionReturning(ctx context.Context, arg StarExpansionR } const starExpansionSubquery = `-- name: StarExpansionSubquery :many -SELECT a, c FROM (SELECT a, c FROM bar) sub +SELECT a, c FROM (SELECT a, c FROM bar) AS sub ` func (q *Queries) StarExpansionSubquery(ctx context.Context) ([]Bar, error) { @@ -252,7 +252,7 @@ func (q *Queries) StarExpansionSubquery(ctx context.Context) ([]Bar, error) { } const starQuotedExpansion = `-- name: StarQuotedExpansion :many -SELECT t.a, t.b, t."group" FROM foo "t" +SELECT t.a, t.b, t."group" FROM foo AS t ` func (q *Queries) StarQuotedExpansion(ctx context.Context) ([]Foo, error) { diff --git a/internal/endtoend/testdata/star_expansion_core/sqlite/query.sql b/internal/endtoend/testdata/star_expansion_core/sqlite/query.sql index 0055fe7d5b..2fb7ec1b7f 100644 --- a/internal/endtoend/testdata/star_expansion_core/sqlite/query.sql +++ b/internal/endtoend/testdata/star_expansion_core/sqlite/query.sql @@ -2,13 +2,13 @@ SELECT *, *, foo.* FROM foo; -- name: StarQuotedExpansion :many -SELECT "t".* FROM foo "t"; +SELECT t.* FROM foo AS t; -- name: StarExpansionJoin :many SELECT * FROM foo, bar; -- name: StarExpansionSubquery :many -SELECT * FROM (SELECT * FROM bar) sub; +SELECT * FROM (SELECT * FROM bar) AS sub; -- name: StarExpansionCTE :many WITH t AS (SELECT * FROM bar) SELECT * FROM t; diff --git a/internal/endtoend/testdata/table_function/sqlite/go/query.sql.go b/internal/endtoend/testdata/table_function/sqlite/go/query.sql.go index 4aa5bf18ab..2ee3387a50 100644 --- a/internal/endtoend/testdata/table_function/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/table_function/sqlite/go/query.sql.go @@ -11,15 +11,12 @@ import ( const getTransaction = `-- name: GetTransaction :many SELECT - json_extract(transactions.data, '$.transaction.signatures[0]'), - json_group_array(instructions.value) -FROM - transactions, - json_each(json_extract(transactions.data, '$.transaction.message.instructions')) AS instructions -WHERE - transactions.program_id = ? - AND json_extract(transactions.data, '$.transaction.signatures[0]') > ? - AND json_extract(json_extract(transactions.data, '$.transaction.message.accountKeys'), '$[' || json_extract(instructions.value, '$.programIdIndex') || ']') = transactions.program_id + json_extract(transactions.data, '$.transaction.signatures[0]'), + json_group_array(instructions.value) +FROM transactions, json_each(json_extract(transactions.data, '$.transaction.message.instructions')) AS instructions +WHERE transactions.program_id = ? + AND json_extract(transactions.data, '$.transaction.signatures[0]') > ? + AND json_extract(json_extract(transactions.data, '$.transaction.message.accountKeys'), '$[' || json_extract(instructions.value, '$.programIdIndex') || ']') = transactions.program_id GROUP BY transactions.rowid LIMIT ? ` diff --git a/internal/endtoend/testdata/table_function/sqlite/query.sql b/internal/endtoend/testdata/table_function/sqlite/query.sql index 867e1114cb..6b79cdca84 100644 --- a/internal/endtoend/testdata/table_function/sqlite/query.sql +++ b/internal/endtoend/testdata/table_function/sqlite/query.sql @@ -1,13 +1,10 @@ /* name: GetTransaction :many */ SELECT - json_extract(transactions.data, '$.transaction.signatures[0]'), - json_group_array(instructions.value) -FROM - transactions, - json_each(json_extract(transactions.data, '$.transaction.message.instructions')) AS instructions -WHERE - transactions.program_id = ? - AND json_extract(transactions.data, '$.transaction.signatures[0]') > ? - AND json_extract(json_extract(transactions.data, '$.transaction.message.accountKeys'), '$[' || json_extract(instructions.value, '$.programIdIndex') || ']') = transactions.program_id + json_extract(transactions.data, '$.transaction.signatures[0]'), + json_group_array(instructions.value) +FROM transactions, json_each(json_extract(transactions.data, '$.transaction.message.instructions')) AS instructions +WHERE transactions.program_id = ? + AND json_extract(transactions.data, '$.transaction.signatures[0]') > ? + AND json_extract(json_extract(transactions.data, '$.transaction.message.accountKeys'), '$[' || json_extract(instructions.value, '$.programIdIndex') || ']') = transactions.program_id GROUP BY transactions.rowid LIMIT ?; diff --git a/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/go/query.sql.go b/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/go/query.sql.go index b7969b21ef..6963209e6b 100644 --- a/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/go/query.sql.go @@ -20,7 +20,7 @@ func (q *Queries) DeleteAuthor(ctx context.Context, id int64) error { } const deleteBook = `-- name: DeleteBook :exec -DELETE FROM Books WHERE id = ? +DELETE FROM books WHERE id = ? ` func (q *Queries) DeleteBook(ctx context.Context, id int64) error { @@ -58,7 +58,7 @@ func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) { } const getBook = `-- name: GetBook :one -SELECT id, title FROM Books WHERE id = ? +SELECT id, title FROM books WHERE id = ? ` func (q *Queries) GetBook(ctx context.Context, id int64) (Book, error) { @@ -100,7 +100,7 @@ func (q *Queries) InsertAuthor(ctx context.Context, name sql.NullString) error { } const insertBook = `-- name: InsertBook :exec -INSERT INTO Books (title) VALUES (?) +INSERT INTO books (title) VALUES (?) ` func (q *Queries) InsertBook(ctx context.Context, title sql.NullString) error { @@ -141,7 +141,7 @@ func (q *Queries) UpdateAuthor(ctx context.Context, arg UpdateAuthorParams) erro } const updateBook = `-- name: UpdateBook :exec -UPDATE Books SET title = ? WHERE id = ? +UPDATE books SET title = ? WHERE id = ? ` type UpdateBookParams struct { diff --git a/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/query.sql b/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/query.sql index 6312be57a5..daaa164168 100644 --- a/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/query.sql +++ b/internal/endtoend/testdata/table_name_case_sensitivity/sqlite/query.sql @@ -8,7 +8,7 @@ INSERT INTO users (name) VALUES (?); INSERT INTO "Authors" (name) VALUES (?); -- name: InsertBook :exec -INSERT INTO Books (title) VALUES (?); +INSERT INTO books (title) VALUES (?); -- name: UpdateUser :exec UPDATE users SET name = ? WHERE id = ?; @@ -20,7 +20,7 @@ UPDATE users SET name = ? WHERE id = ?; UPDATE "Authors" SET name = ? WHERE id = ?; -- name: UpdateBook :exec -UPDATE Books SET title = ? WHERE id = ?; +UPDATE books SET title = ? WHERE id = ?; -- name: DeleteUser :exec DELETE FROM users WHERE id = ?; @@ -32,7 +32,7 @@ DELETE FROM users WHERE id = ?; DELETE FROM "Authors" WHERE id = ?; -- name: DeleteBook :exec -DELETE FROM Books WHERE id = ?; +DELETE FROM books WHERE id = ?; -- name: GetUser :one SELECT * FROM users WHERE id = ?; @@ -44,4 +44,4 @@ SELECT * FROM users WHERE id = ?; SELECT * FROM "Authors" WHERE id = ?; -- name: GetBook :one -SELECT * FROM Books WHERE id = ?; +SELECT * FROM books WHERE id = ?; diff --git a/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/db/query.sql.go b/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/db/query.sql.go index 474372161d..faef31678f 100644 --- a/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/db/query.sql.go +++ b/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/db/query.sql.go @@ -10,7 +10,7 @@ import ( ) const getRepro = `-- name: GetRepro :one -select id, name, seq from repro where id = ? limit 1 +SELECT id, name, seq FROM repro WHERE id = ? LIMIT 1 ` func (q *Queries) GetRepro(ctx context.Context, id any) (Repro, error) { diff --git a/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/query.sql b/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/query.sql index b90ec62481..b3923f261f 100644 --- a/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/query.sql +++ b/internal/endtoend/testdata/untyped_columns/sqlite/stdlib/query.sql @@ -1,2 +1,2 @@ -- name: GetRepro :one -select * from repro where id = ? limit 1; \ No newline at end of file +SELECT * FROM repro WHERE id = ? LIMIT 1; diff --git a/internal/endtoend/testdata/upsert/sqlite/go/query.sql.go b/internal/endtoend/testdata/upsert/sqlite/go/query.sql.go index c43dbaf869..8a5227da4e 100644 --- a/internal/endtoend/testdata/upsert/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/upsert/sqlite/go/query.sql.go @@ -11,19 +11,19 @@ import ( const upsertLocation = `-- name: UpsertLocation :exec INSERT INTO locations ( - name, - address, - zip_code, - latitude, - longitude + name, + address, + zip_code, + latitude, + longitude ) VALUES (?, ?, ?, ?, ?) -ON CONFLICT(name) DO UPDATE SET - name = excluded.name, - address = excluded.address, - zip_code = excluded.zip_code, - latitude = excluded.latitude, - longitude = excluded.longitude +ON CONFLICT (name) DO UPDATE SET + name = excluded.name, + address = excluded.address, + zip_code = excluded.zip_code, + latitude = excluded.latitude, + longitude = excluded.longitude ` type UpsertLocationParams struct { diff --git a/internal/endtoend/testdata/upsert/sqlite/query.sql b/internal/endtoend/testdata/upsert/sqlite/query.sql index c34d70b407..2bcc90219b 100644 --- a/internal/endtoend/testdata/upsert/sqlite/query.sql +++ b/internal/endtoend/testdata/upsert/sqlite/query.sql @@ -1,15 +1,15 @@ /* name: UpsertLocation :exec */ INSERT INTO locations ( - name, - address, - zip_code, - latitude, - longitude + name, + address, + zip_code, + latitude, + longitude ) VALUES (?, ?, ?, ?, ?) -ON CONFLICT(name) DO UPDATE SET - name = excluded.name, - address = excluded.address, - zip_code = excluded.zip_code, - latitude = excluded.latitude, - longitude = excluded.longitude; +ON CONFLICT (name) DO UPDATE SET + name = excluded.name, + address = excluded.address, + zip_code = excluded.zip_code, + latitude = excluded.latitude, + longitude = excluded.longitude; diff --git a/internal/endtoend/testdata/virtual_table/sqlite/go/query.sql.go b/internal/endtoend/testdata/virtual_table/sqlite/go/query.sql.go index 1ba464841d..b042473394 100644 --- a/internal/endtoend/testdata/virtual_table/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/virtual_table/sqlite/go/query.sql.go @@ -19,7 +19,7 @@ func (q *Queries) DeleteTblFt(ctx context.Context, b string) error { } const insertTblFt = `-- name: InsertTblFt :exec -INSERT INTO tbl_ft(b, c) VALUES(?, ?) +INSERT INTO tbl_ft (b, c) VALUES (?, ?) ` type InsertTblFtParams struct { @@ -33,7 +33,8 @@ func (q *Queries) InsertTblFt(ctx context.Context, arg InsertTblFtParams) error } const selectAllColsFt = `-- name: SelectAllColsFt :many -SELECT b FROM ft +SELECT b +FROM ft WHERE b MATCH ? ` @@ -61,7 +62,8 @@ func (q *Queries) SelectAllColsFt(ctx context.Context, b string) ([]string, erro } const selectAllColsTblFt = `-- name: SelectAllColsTblFt :many -SELECT b, c FROM tbl_ft +SELECT b, c +FROM tbl_ft WHERE b MATCH ? ` @@ -89,8 +91,10 @@ func (q *Queries) SelectAllColsTblFt(ctx context.Context, b string) ([]TblFt, er } const selectBm25Func = `-- name: SelectBm25Func :many -SELECT b, c, bm25(tbl_ft, 2.0) FROM tbl_ft -WHERE b MATCH ? ORDER BY bm25(tbl_ft) +SELECT b, c, bm25(tbl_ft, 2.0) +FROM tbl_ft +WHERE b MATCH ? +ORDER BY bm25(tbl_ft) ` type SelectBm25FuncRow struct { @@ -123,7 +127,8 @@ func (q *Queries) SelectBm25Func(ctx context.Context, b string) ([]SelectBm25Fun } const selectHightlighFunc = `-- name: SelectHightlighFunc :many -SELECT highlight(tbl_ft, 0, '', '') FROM tbl_ft +SELECT highlight(tbl_ft, 0, '', '') +FROM tbl_ft WHERE b MATCH ? ` @@ -151,7 +156,8 @@ func (q *Queries) SelectHightlighFunc(ctx context.Context, b string) ([]string, } const selectOneColFt = `-- name: SelectOneColFt :many -SELECT b FROM ft +SELECT b +FROM ft WHERE b = ? ` @@ -179,7 +185,8 @@ func (q *Queries) SelectOneColFt(ctx context.Context, b string) ([]string, error } const selectOneColTblFt = `-- name: SelectOneColTblFt :many -SELECT c FROM tbl_ft +SELECT c +FROM tbl_ft WHERE b = ? ` diff --git a/internal/endtoend/testdata/virtual_table/sqlite/query.sql b/internal/endtoend/testdata/virtual_table/sqlite/query.sql index 5646d5034e..002e90f887 100644 --- a/internal/endtoend/testdata/virtual_table/sqlite/query.sql +++ b/internal/endtoend/testdata/virtual_table/sqlite/query.sql @@ -1,29 +1,36 @@ -- name: SelectAllColsFt :many -SELECT b FROM ft +SELECT b +FROM ft WHERE b MATCH ?; -- name: SelectAllColsTblFt :many -SELECT b, c FROM tbl_ft +SELECT b, c +FROM tbl_ft WHERE b MATCH ?; -- name: SelectOneColFt :many -SELECT b FROM ft +SELECT b +FROM ft WHERE b = ?; -- name: SelectOneColTblFt :many -SELECT c FROM tbl_ft +SELECT c +FROM tbl_ft WHERE b = ?; -- name: SelectHightlighFunc :many -SELECT highlight(tbl_ft, 0, '', '') FROM tbl_ft +SELECT highlight(tbl_ft, 0, '', '') +FROM tbl_ft WHERE b MATCH ?; -- name: SelectSnippetFunc :many SELECT snippet(tbl_ft, 0, '', '', 'aa', ?) FROM tbl_ft; -- name: SelectBm25Func :many -SELECT b, c, bm25(tbl_ft, 2.0) FROM tbl_ft -WHERE b MATCH ? ORDER BY bm25(tbl_ft); +SELECT b, c, bm25(tbl_ft, 2.0) +FROM tbl_ft +WHERE b MATCH ? +ORDER BY bm25(tbl_ft); -- name: UpdateTblFt :exec UPDATE tbl_ft SET c = ? WHERE b = ?; @@ -32,4 +39,4 @@ UPDATE tbl_ft SET c = ? WHERE b = ?; DELETE FROM tbl_ft WHERE b = ?; -- name: InsertTblFt :exec -INSERT INTO tbl_ft(b, c) VALUES(?, ?); +INSERT INTO tbl_ft (b, c) VALUES (?, ?); diff --git a/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/go/query.sql.go b/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/go/query.sql.go index d815d9999b..7fe6d32f15 100644 --- a/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/go/query.sql.go @@ -11,7 +11,8 @@ import ( ) const searchRecipes = `-- name: SearchRecipes :many -SELECT rowid, name FROM recipes_fts +SELECT rowid, name +FROM recipes_fts WHERE recipes_fts MATCH ? ` @@ -44,8 +45,10 @@ func (q *Queries) SearchRecipes(ctx context.Context, recipesFts string) ([]Searc } const searchRecipesRanked = `-- name: SearchRecipesRanked :many -SELECT rowid, name, rank FROM recipes_fts -WHERE recipes_fts MATCH ? ORDER BY rank +SELECT rowid, name, rank +FROM recipes_fts +WHERE recipes_fts MATCH ? +ORDER BY rank ` type SearchRecipesRankedRow struct { diff --git a/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/query.sql b/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/query.sql index a539d26108..0b5785ac55 100644 --- a/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/query.sql +++ b/internal/endtoend/testdata/virtual_table_fts5_hidden/sqlite/query.sql @@ -1,7 +1,10 @@ -- name: SearchRecipes :many -SELECT rowid, name FROM recipes_fts +SELECT rowid, name +FROM recipes_fts WHERE recipes_fts MATCH ?; -- name: SearchRecipesRanked :many -SELECT rowid, name, rank FROM recipes_fts -WHERE recipes_fts MATCH ? ORDER BY rank; +SELECT rowid, name, rank +FROM recipes_fts +WHERE recipes_fts MATCH ? +ORDER BY rank; diff --git a/internal/endtoend/testdata/where_collate/sqlite/go/query.sql.go b/internal/endtoend/testdata/where_collate/sqlite/go/query.sql.go index fdc20f7ddb..1f40224e16 100644 --- a/internal/endtoend/testdata/where_collate/sqlite/go/query.sql.go +++ b/internal/endtoend/testdata/where_collate/sqlite/go/query.sql.go @@ -10,8 +10,9 @@ import ( ) const getAccountByName = `-- name: GetAccountByName :one -SELECT id, name FROM accounts -WHERE name = ? COLLATE NOCASE +SELECT id, name +FROM accounts +WHERE name = ? COLLATE nocase LIMIT 1 ` diff --git a/internal/endtoend/testdata/where_collate/sqlite/query.sql b/internal/endtoend/testdata/where_collate/sqlite/query.sql index 647c3ebc07..88568bf0b9 100644 --- a/internal/endtoend/testdata/where_collate/sqlite/query.sql +++ b/internal/endtoend/testdata/where_collate/sqlite/query.sql @@ -1,4 +1,5 @@ -- name: GetAccountByName :one -SELECT * FROM accounts -WHERE name = ? COLLATE NOCASE -LIMIT 1; \ No newline at end of file +SELECT * +FROM accounts +WHERE name = ? COLLATE nocase +LIMIT 1;