Errors
This page documents every error code (HSQL1001–HSQL9007) that hyper-sql's mapper and hyper-sql pull can produce, what causes each one, and how to fix it.
Mapper errors appear in TypeScript as Problem<"HSQLxxxx: ..."> diagnostics anchored to the exact line in your .sql file, and option errors are reported by TypeScript with the HSQL diagnostic source (HSQL9001–HSQL9007). Each entry below links to a runnable reproduction in the playground. In the message templates, placeholders like x, p, and t stand for your own column, parameter, or table names.
Code ranges
| Range | Family | Covers |
|---|---|---|
HSQL1001–HSQL1003 | Lock | Missing, unreadable, or stale sql.lock |
HSQL2001–HSQL2003 | Lexer | Unclosed strings, quoted names, or block comments |
HSQL3001–HSQL3020 | Annotations | -- @name, -- @one/@many/@exec, -- @param, -- @col, -- @import, -- @type |
HSQL4001–HSQL4007 | SQL shape | Statement outline, brackets, WITH, FROM, joins, MERGE |
HSQL5001–HSQL5005 | Typing | NATURAL JOIN, USING, ambiguous/duplicate columns, unresolvable * |
HSQL6001–HSQL6010 | Needs annotation | Columns or parameters whose types require -- @col or -- @param |
HSQL7001–HSQL7030 | Dynamic parts | /*if*/, /*on*///*off*/, /*sort*/, and /*end*/ blocks |
HSQL8001–HSQL8010 | Pull | Schema, STRICT, database prepare errors, DATABASE_URL, Postgres parameter types |
HSQL9001–HSQL9007 | Options | contentMappers options in tsconfig.json |
HSQL1001 — lock-missing
Message: HSQL1001: sql.lock not found: run hyper-sql pull
Example output: HSQL1001: sql.lock not found: run hyper-sql pull
File: src/query.sql
SELECT isbn, title FROM booksThis project has no sql.lock file yet. Because hyper-sql never connects to a database during builds, TypeScript needs sql.lock to know your query types.
Fix: Run hyper-sql pull in the project directory and commit sql.lock.
Example: examples/errors/lock-missing
HSQL1002 — lock-unreadable
Message: HSQL1002: sql.lock is not a lock file (the file is not an object): run hyper-sql pull
Example output: HSQL1002: sql.lock is not a lock file (the file is not an object): run hyper-sql pull
File: sql.lock
[]sql.lock exists, but its contents ([]) aren't a valid lock object—usually the result of a manual edit or a bad merge conflict.
Fix: Run hyper-sql pull to regenerate sql.lock cleanly.
Example: examples/errors/lock-unreadable
HSQL1003 — lock-stale
Message: HSQL1003: changed since the last sql pull: run hyper-sql pull
Example output: src/query.sql:1:1: HSQL1003: changed since the last sql pull: run hyper-sql pull
File: src/query.sql
SELECT isbn, title, price_cents FROM bookssrc/query.sql was edited after sql.lock was generated (sql.lock still reflects SELECT isbn, title FROM books), so the lock is out of sync with your SQL.
Fix: Run hyper-sql pull and commit the updated sql.lock.
Example: examples/errors/lock-stale
HSQL2001 — unclosed-string
Message: HSQL2001: unclosed string: add the closing '
Example output: src/query.sql:1:39: HSQL2001: unclosed string: add the closing '
File: src/query.sql
SELECT title FROM books WHERE title = 'DuneA single-quoted string opens at line 1, column 39, and never closes before the end of the file.
Fix: Add the closing quote: WHERE title = 'Dune'.
Example: examples/errors/unclosed-string
HSQL2002 — unclosed-quoted-name
Message: HSQL2002: unclosed quoted name: add the closing ]
Example output: src/query.sql:1:8: HSQL2002: unclosed quoted name: add the closing ]
File: src/query.sql
SELECT [title FROM booksA bracket-quoted identifier opens with [ at line 1, column 8, without a matching ], causing the rest of the file to be parsed as part of that name.
Fix: Close the identifier: SELECT [title] FROM books.
Example: examples/errors/unclosed-quoted-name
HSQL2003 — unclosed-comment
Message: HSQL2003: unclosed comment: add the closing */
Example output: src/query.sql:1:1: HSQL2003: unclosed comment: add the closing */
File: src/query.sql
/* all titles
SELECT title FROM booksA block comment opens with /* at line 1, column 1, and never closes, swallowing the entire file including the query.
Fix: Add a closing */ at the end of the comment.
Example: examples/errors/unclosed-comment
HSQL3001 — annotation-unknown-tag
Message: HSQL3001: unknown annotation @colm
Example output: src/query.sql: HSQL3001: unknown annotation @colm
File: src/query.sql
-- @colm title: string
SELECT title FROM booksLines starting with -- @ are parsed as hyper-sql annotations, and @colm isn't a recognized tag. Valid tags are name, one, many, exec, param, col, import, and type.
Fix: Fix the typo: -- @col title: string.
Example: examples/errors/annotation-unknown-tag
HSQL3002 — annotation-form
Message: HSQL3002: malformed annotation: write -- @one
Example output: src/query.sql: HSQL3002: malformed annotation: write -- @one
File: src/query.sql
-- @one now
SELECT title FROM books WHERE isbn = :isbnThe -- @one annotation doesn't take any arguments, so trailing text on the same line is rejected.
Fix: Put -- @one on its own line with nothing after it.
Example: examples/errors/annotation-form
HSQL3003 — annotation-second-result
Message: HSQL3003: second result annotation
Example output: src/query.sql: HSQL3003: second result annotation
File: src/query.sql
-- @one
-- @many
SELECT title FROM books WHERE isbn = :isbnA statement can only have one result-shape annotation (@one, @many, or @exec), but this query specifies two.
Fix: Remove the extra annotation and keep only the one you want (-- @one or -- @many).
Example: examples/errors/annotation-second-result
HSQL3004 — annotation-second-name
Message: HSQL3004: second statement named x
Example output: src/query.sql: HSQL3004: second statement named titles
File: src/query.sql
-- @name titles
SELECT title FROM books
-- @name titles
SELECT title FROM booksTwo statements in the same file are both named titles. Each -- @name becomes an exported function, so names must be unique within a file.
Fix: Rename the second statement or remove the duplicate.
Example: examples/errors/annotation-second-name
HSQL3005 — annotation-second-declare
Message: HSQL3005: second annotation for column x
Example output: src/query.sql: HSQL3005: second annotation for column title
File: src/query.sql
-- @col title: string
-- @col title: string
SELECT title FROM booksThe column title has two -- @col annotations, but each column can only be declared once.
Fix: Keep a single -- @col title: string annotation.
Example: examples/errors/annotation-second-declare
HSQL3006 — annotation-before-name
Message: HSQL3006: annotation before the first @name
Example output: src/query.sql: HSQL3006: annotation before the first @name
File: src/query.sql
-- @one
-- @name titles
SELECT title FROM booksIn a multi-statement file, each statement's annotations must appear after its -- @name line. Here -- @one appears before the first -- @name, so it isn't attached to any statement.
Fix: Move -- @name titles above -- @one.
Example: examples/errors/annotation-before-name
HSQL3007 — annotation-sql-before-name
Message: HSQL3007: SQL before the first @name: start the statement with -- @name x
Example output: src/query.sql: HSQL3007: SQL before the first @name: start the statement with -- @name x
File: src/query.sql
SELECT 1;
-- @name titles
SELECT title FROM booksOnce a file uses -- @name, every statement in that file must be named. Here a SQL statement appears before the first -- @name.
Fix: Add -- @name <name> above the first statement, or remove the extra SQL.
Example: examples/errors/annotation-sql-before-name
HSQL3008 — annotation-type-no-column
Message: HSQL3008: @type is on no column: write it on the line where the column starts
Example output: schema.sql: HSQL3008: @type is on no column: write it on the line where the column starts
File: schema.sql
CREATE TABLE authors (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE books (
isbn TEXT PRIMARY KEY,
title TEXT NOT NULL,
author_id INTEGER NOT NULL REFERENCES authors (id),
price_cents INTEGER NOT NULL
) STRICT;
-- @type Isbn from './types.ts'A -- @type annotation in schema.sql must sit on the line where its column definition starts, but this one appears after the table definition with no column attached.
Fix: Move the -- @type annotation onto the column's starting line, or remove it.
Example: examples/errors/annotation-type-no-column
HSQL3009 — annotation-type-not-in-schema
Message: HSQL3009: no column t.c in the schema: run hyper-sql pull, or write the annotation on a column that the lock has
Example output: schema.sql: HSQL3009: no column scratch.id in the schema: run hyper-sql pull, or write the annotation on a column that the lock has
File: schema.sql
CREATE TABLE authors (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE books (
isbn TEXT PRIMARY KEY,
title TEXT NOT NULL,
author_id INTEGER NOT NULL REFERENCES authors (id),
price_cents INTEGER NOT NULL
) STRICT;
CREATE TABLE scratch (
id INTEGER PRIMARY KEY, -- @type ScratchId from './types.ts'
name TEXT
) STRICT;
DROP TABLE scratch;schema.sql attaches -- @type to scratch.id, but the scratch table is dropped later in the file, so it doesn't exist in sql.lock.
Fix: Attach -- @type only to columns on tables that remain in the schema, or remove the annotation.
Example: examples/errors/annotation-type-not-in-schema
HSQL3010 — annotation-type-name-taken
Message: HSQL3010: x is already a name in schema.sql.ts (a table interface or a check type): give the type another name
Example output: schema.sql: HSQL3010: Authors is already a name in schema.sql.ts (a table interface or a check type): give the type another name
File: schema.sql
CREATE TABLE authors (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE books (
isbn TEXT PRIMARY KEY,
title TEXT NOT NULL,
author_id INTEGER NOT NULL REFERENCES authors (id), -- @type Authors from './types.ts'
price_cents INTEGER NOT NULL
) STRICT;The -- @type annotation imports a type named Authors, which collides with the table interface Authors generated for the authors table in schema.sql.ts.
Fix: Rename the imported type (for example AuthorId) to avoid the collision.
Example: examples/errors/annotation-type-name-taken
HSQL3011 — annotation-two-sources
Message: HSQL3011: x is imported from two files: import each type name from one file
Example output: schema.sql: HSQL3011: Code is imported from two files: import each type name from one file
File: schema.sql
CREATE TABLE authors (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE books (
isbn TEXT PRIMARY KEY, -- @type Code from './a.ts'
title TEXT NOT NULL, -- @type Code from './b.ts'
author_id INTEGER NOT NULL REFERENCES authors (id),
price_cents INTEGER NOT NULL
) STRICT;Two -- @type annotations import the same type name Code from two different files (./a.ts and ./b.ts), which can't coexist in one generated module.
Fix: Import Code from a single file, or give one of the types a distinct name.
Example: examples/errors/annotation-two-sources
HSQL3012 — annotation-column-type
Message: HSQL3012: column t.c: the database type geometry has no TypeScript type here; add -- @type <type> on the column
Example output: schema.sql: HSQL3012: column flights.gate: the database type point has no TypeScript type here; add -- @type <type> on the column
File: schema.sql
CREATE TABLE flights (
id integer PRIMARY KEY,
code text NOT NULL,
departs_at timestamptz NOT NULL,
seats integer NOT NULL,
gate point
);
CREATE TABLE passengers (
id integer PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE bookings (
id integer PRIMARY KEY,
flight_id integer NOT NULL REFERENCES flights (id),
passenger_id integer NOT NULL REFERENCES passengers (id)
);flights.gate has Postgres type point, which has no built-in TypeScript mapping in hyper-sql.
Fix: Add a -- @type annotation on the column in schema.sql, such as gate point -- @type Gate from ./types.ts.
Example: examples/errors/annotation-column-type
HSQL3013 — annotation-no-column
Message: HSQL3013: no column x in q
Example output: src/query.sql: HSQL3013: no column price in query
File: src/query.sql
-- @col price: number
SELECT title FROM booksThe query has a -- @col price annotation, but it doesn't select any output column named price.
Fix: Target an actual output column (such as -- @col title: string), or remove the unused annotation.
Example: examples/errors/annotation-no-column
HSQL3014 — annotation-no-param
Message: HSQL3014: no parameter :x in q
Example output: src/query.sql: HSQL3014: no parameter :key in query
File: src/query.sql
-- @param key: string
SELECT title FROM booksThe query has a -- @param key annotation, but :key isn't used anywhere in the SQL.
Fix: Use :key in the query (for example WHERE isbn = :key), or remove the unused annotation.
Example: examples/errors/annotation-no-param
HSQL3015 — annotation-one-on-dml
Message: HSQL3015: @one on a statement that changes data: the change is made before a second row shows, so use @many
Example output: src/query.sql: HSQL3015: @one on a statement that changes data: the change is made before a second row shows, so use @many
File: src/query.sql
-- @one
DELETE FROM orders WHERE id = :id-- @one throws if a query returns a second row, but INSERT, UPDATE, and DELETE have already mutated the database by the time rows come back. Because of that, -- @one isn't allowed on write statements, even single-row ones.
Fix: Use -- @many (with const [row] = f(db, ...) for RETURNING), or -- @exec if you don't need rows back. Reserve -- @one for SELECT queries.
Example: examples/errors/annotation-one-on-dml
HSQL3016 — annotation-export-name
Message: HSQL3016: x cannot be an export name (it is a TypeScript reserved word, a name that the module imports, a name that starts with sql_, or its type names belong to another statement): write -- @name x with another name
Example output: src/query.sql: HSQL3016: default cannot be an export name (it is a TypeScript reserved word, a name that the module imports, a name that starts with sql_, or its type names belong to another statement): write -- @name x with another name
File: src/query.sql
-- @name default
SELECT title FROM booksStatement names become exported TypeScript functions, and default is a reserved keyword in TypeScript.
Fix: Choose a valid identifier with -- @name, such as -- @name defaultTitles.
Example: examples/errors/annotation-export-name
HSQL3017 — annotation-check-column
Message: HSQL3017: column t.c is INTEGER, and the check form reads JSON text: write the annotation on a TEXT (SQLite) or json or jsonb (Postgres) column, or write it without check
Example output: schema.sql: HSQL3017: column books.price_cents is INTEGER, and the check form reads JSON text: write the annotation on a TEXT (SQLite) or json or jsonb (Postgres) column, or write it without check
File: schema.sql
CREATE TABLE authors (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE books (
isbn TEXT PRIMARY KEY,
title TEXT NOT NULL,
author_id INTEGER NOT NULL REFERENCES authors (id),
price_cents INTEGER NOT NULL -- @type Money check isMoney from './money.ts'
) STRICT;The check form of -- @type parses and validates JSON text, so it can't be placed on an INTEGER column like price_cents.
Fix: Use check only on a TEXT (SQLite) or json/jsonb (Postgres) column, or drop the check clause.
Example: examples/errors/annotation-check-column
HSQL3018 — annotation-unproven
Message: HSQL3018: the annotation's type is not proven by the database type: write the type itself, a brand over it or a union of string or number literals, and write boolean, Date or the JSON check form in the annotation itself
Example output: src/query.sql: HSQL3018: the annotation's type is not proven by the database type: write the type itself, a brand over it or a union of string or number literals, and write boolean, Date or the JSON check form in the annotation itself
File: src/query.sql
-- @param key: number
SELECT title FROM books WHERE isbn = :keyThe annotation declares :key as number, but isbn is a TEXT column (string). Annotations can narrow or brand a compatible type, but can't change it to an unrelated primitive.
Fix: Match the column's underlying type: -- @param key: string.
Example: examples/errors/annotation-unproven
HSQL3019 — annotation-no-read
Message: HSQL3019: column x: the run time has no read for its type (a Postgres array of json or jsonb): select it as JSON, to_jsonb(x), or as text, x::text
Example output: src/query.sql: HSQL3019: column tags: the run time has no read for its type (a Postgres array of json or jsonb): select it as JSON, to_jsonb(tags), or as text, tags::text
File: src/query.sql
SELECT code, tags FROM flightstags is a Postgres jsonb[] column. hyper-sql decodes arrays of primitives and enums, but doesn't have a built-in decoder for arrays of JSON.
Fix: Select it as JSON with to_jsonb(tags) or cast it to text with tags::text.
Example: examples/errors/annotation-no-read
HSQL3020 — annotation-no-read-param
Message: HSQL3020: parameter x: the run time has no bind for its type (a Postgres array whose elements are not numbers, text, booleans or enum labels): pass the elements as text and cast, :x::text[]
Example output: src/query.sql: HSQL3020: parameter tags: the run time has no bind for its type (a Postgres array whose elements are not numbers, text, booleans or enum labels): pass the elements as text and cast, :tags::text[]
File: src/query.sql
SELECT id FROM flights WHERE tags = :tags:tags is compared against a Postgres jsonb[] column. hyper-sql binds array parameters for numbers, strings, booleans, and enums, but not arrays of JSON.
Fix: Pass the elements as a text array and cast in SQL: :tags::text[]::jsonb[].
Example: examples/errors/annotation-no-read-param
HSQL4001 — shape-unbalanced
Message: HSQL4001: bracket ( has no match: add the matching bracket
No example: The database catches an unbalanced parenthesis first, before hyper-sql parses the query.
HSQL4002 — shape-statement
Message: HSQL4002: a statement is a SELECT, INSERT, UPDATE, DELETE or MERGE (Postgres), after any WITH list, not PRAGMA: run it on the raw database handle
Example output: src/query.sql: HSQL4002: a statement is a SELECT, INSERT, UPDATE, DELETE or MERGE (Postgres), after any WITH list, not PRAGMA: run it on the raw database handle
File: src/query.sql
PRAGMA table_info(books)Query files only support SELECT, INSERT, UPDATE, DELETE, and Postgres MERGE statements (optionally prefixed with WITH), so PRAGMA isn't allowed here.
Fix: Run PRAGMA statements directly on your raw database driver in TypeScript instead.
Example: examples/errors/shape-statement
HSQL4003 — shape-with
Message: HSQL4003: WITH list: write name [(columns)] AS (statement), one for each CTE
Example output: src/query.sql: HSQL4003: WITH list: write name [(columns)] AS (statement), one for each CTE
File: src/query.sql
WITH 'x' AS (SELECT isbn FROM books) SELECT isbn FROM xSQLite allows a single-quoted string ('x') as a CTE name, but hyper-sql expects standard SQL identifiers in WITH name [(columns)] AS (...).
Fix: Use an unquoted or double-quoted identifier: WITH x AS (SELECT isbn FROM books) SELECT isbn FROM x.
Example: examples/errors/shape-with
HSQL4004 — shape-from
Message: HSQL4004: FROM item: write a table, a function call or a (subquery), then its alias
Example output: src/query.sql: HSQL4004: FROM item: write a table, a function call or a (subquery), then its alias
File: src/query.sql
SELECT isbn FROM 'books'SQLite allows a single-quoted string ('books') as a table name, but hyper-sql requires a table identifier, table function, or (subquery) in FROM.
Fix: Remove the single quotes (or use double quotes): SELECT isbn FROM books.
Example: examples/errors/shape-from
HSQL4005 — shape-nested-join
Message: HSQL4005: a join has a second ON or USING here: write the nested join in brackets, a LEFT JOIN (b JOIN c ON ..) ON ..
Example output: src/query.sql: HSQL4005: a join has a second ON or USING here: write the nested join in brackets, a LEFT JOIN (b JOIN c ON ..) ON ..
File: src/query.sql
SELECT f.code, p.name FROM flights f JOIN bookings b JOIN passengers p ON p.id = b.passenger_id ON b.flight_id = f.idPostgres allows chained JOIN ... JOIN ... ON ... ON ... without parentheses, which hyper-sql's parser doesn't accept.
Fix: Parenthesize the nested join explicitly: FROM flights f JOIN (bookings b JOIN passengers p ON p.id = b.passenger_id) ON b.flight_id = f.id.
Example: examples/errors/shape-nested-join
HSQL4006 — shape-merge
Message: HSQL4006: MERGE: write MERGE INTO t [AS a] USING s [AS b] ON condition, then one or more WHEN [NOT] MATCHED [BY SOURCE | BY TARGET] [AND condition] THEN UPDATE SET …, INSERT … VALUES (…), DELETE or DO NOTHING
No example: Postgres rejects a MERGE missing USING, ON, or a WHEN clause before hyper-sql sees it, and SQLite doesn't support MERGE.
HSQL4007 — shape-statement-empty
Message: HSQL4007: empty statement: write a SELECT, INSERT, UPDATE, DELETE or MERGE
No example: SQLite reports "The SQL query contains no statements." before hyper-sql inspects the file.
HSQL5001 — typing-natural
Message: HSQL5001: NATURAL JOIN: use ON with qualified columns
Example output: src/query.sql: HSQL5001: NATURAL JOIN: use ON with qualified columns
File: src/query.sql
SELECT b.title, a.name FROM books b NATURAL JOIN authors aNATURAL JOIN implicitly joins on any shared column names, making the join columns invisible in the SQL and fragile whenever a table gains a column.
Fix: Write an explicit ON clause with qualified columns: JOIN authors a ON a.id = b.author_id.
Example: examples/errors/typing-natural
HSQL5002 — typing-using
Message: HSQL5002: JOIN .. USING: use ON with qualified columns
Example output: src/query.sql: HSQL5002: JOIN .. USING: use ON with qualified columns
File: src/query.sql
SELECT o.id, b.title FROM orders o JOIN books b USING (isbn)JOIN ... USING merges columns from both tables into a single unqualified column, which hyper-sql doesn't support.
Fix: Use an explicit ON clause with qualified columns: JOIN books b ON b.isbn = o.isbn.
Example: examples/errors/typing-using
HSQL5003 — typing-ambiguous
Message: HSQL5003: column x is in more than one FROM item: qualify it, a.x
No example: The database reports an ambiguous column error (ambiguous column name on SQLite, column reference is ambiguous on Postgres) first.
HSQL5004 — typing-star
Message: HSQL5004: * cannot list the columns of x: write the columns by name
Example output: src/query.sql: HSQL5004: * cannot list the columns of j: write the columns by name
File: src/query.sql
SELECT j.* FROM pragma_table_info('books') jThe query uses j.* on a table function (pragma_table_info) whose columns hyper-sql can't expand automatically (only json_each and json_tree have built-in column definitions on SQLite).
Fix: List the columns explicitly (e.g. j.name) and add a -- @col annotation for each one.
Example: examples/errors/typing-star
HSQL5005 — typing-duplicate
Message: HSQL5005: two output columns are named x: give one of them an alias, AS another_name
Example output: src/query.sql: HSQL5005: two output columns are named isbn: give one of them an alias, AS another_name
File: src/query.sql
SELECT b.isbn, o.isbn FROM books b JOIN orders o ON o.isbn = b.isbnThe query outputs two columns named isbn. Because each row decodes into a TypeScript object, duplicate column names would overwrite each other.
Fix: Alias one of the columns: SELECT b.isbn, o.isbn AS order_isbn.
Example: examples/errors/typing-duplicate
HSQL6001 — annotate-call
Message: HSQL6001: column x: it may come from a table function or a VALUES list, whose columns the mapper does not know; add -- @col x: <type>
Example output: src/query.sql: HSQL6001: column name: it may come from a table function or a VALUES list, whose columns the mapper does not know; add -- @col name: <type>
File: src/query.sql
SELECT name FROM pragma_table_info('books')name comes from pragma_table_info, a SQLite table function whose output columns hyper-sql doesn't know ahead of time (unlike tables, views, subqueries, json_each, and json_tree).
Fix: Add -- @col name: string above the query.
Example: examples/errors/annotate-call
HSQL6002 — annotate-table
Message: HSQL6002: column x: table t is not in the lock; add -- @col x: <type>
Example output: src/query.sql: HSQL6002: column name: table sqlite_master is not in the lock; add -- @col name: <type>
File: src/query.sql
SELECT name FROM sqlite_mastersqlite_master isn't defined in schema.sql, so sql.lock has no column types for it.
Fix: Add -- @col name: string above the query.
Example: examples/errors/annotate-table
HSQL6003 — annotate-unresolved
Message: HSQL6003: column x: x is no column of one FROM item; add -- @col x: <type>
Example output: src/query.sql: HSQL6003: column rowid: rowid is no column of one FROM item; add -- @col rowid: <type>
File: src/query.sql
SELECT rowid FROM booksrowid is an implicit SQLite column that isn't declared on books in schema.sql, so hyper-sql can't look up its type from sql.lock.
Fix: Add -- @col rowid: number above the query, or select an explicit column from the schema.
Example: examples/errors/annotate-unresolved
HSQL6004 — annotate-expression
Message: HSQL6004: column x: the database cannot solve the type of an expression; add -- @col x: <type>
Example output: src/query.sql: HSQL6004: column doubled: the database cannot solve the type of an expression; add -- @col doubled: <type>
File: src/query.sql
SELECT price_cents * 2 AS doubled FROM booksSQLite doesn't report declared types for computed expressions like price_cents * 2.
Fix: Add -- @col doubled: number above the query.
Example: examples/errors/annotate-expression
HSQL6005 — annotate-origin
Message: HSQL6005: column x: the lock has another source column than the one that the query text gives; add -- @col x: <type>
No example: Rare edge case where the database reports a different origin column than the SQL text implies; add the -- @col annotation shown in the message.
HSQL6006 — annotate-db-type
Message: HSQL6006: column x: the database type geometry has no TypeScript type here; add -- @col x: <type>
Example output: src/query.sql: HSQL6006: column spot: the database type point has no TypeScript type here; add -- @col spot: <type>
File: src/query.sql
SELECT point(1, 2) AS spotPostgres reports spot as type point, which has no built-in TypeScript mapping in hyper-sql.
Fix: Cast it to a supported type (SELECT point(1, 2)::text AS spot), or add -- @col spot: string above the query.
Example: examples/errors/annotate-db-type
HSQL6007 — annotate-shape
Message: HSQL6007: column x: it is not compared with a column of the query, so its type is not known; add -- @col x: <type>
Example output: src/query.sql: HSQL6007: parameter t: it is not compared with a column of the query, so its type is not known; add -- @param t: <type>
File: src/query.sql
SELECT title FROM books WHERE lower(title) = :tOn SQLite, hyper-sql infers parameter types from the column they're compared against, but :t is compared against the expression lower(title) rather than a bare column.
Fix: Add -- @param t: string above the query.
Example: examples/errors/annotate-shape
HSQL6008 — annotate-conflict
Message: HSQL6008: column x: its uses give different types; add -- @col x: <type>
Example output: src/query.sql: HSQL6008: parameter key: its uses give different types; add -- @param key: <type>
File: src/query.sql
SELECT title FROM books WHERE isbn = :key OR price_cents = :key:key is compared against both a TEXT column and an INTEGER column in the same query, so its type is ambiguous.
Fix: Use two separate parameters, or declare the intended type explicitly with -- @param key: string.
Example: examples/errors/annotate-conflict
HSQL6009 — annotate-mixed
Message: HSQL6009: column x: its arguments have different types, and the database cannot solve the type of a call; add -- @col x: <type>
Example output: src/query.sql: HSQL6009: column what: its arguments have different types, and the database cannot solve the type of a call; add -- @col what: <type>
File: src/query.sql
SELECT coalesce(note, quantity) AS what FROM orderscoalesce is called with both a string (note) and a number (quantity), and SQLite doesn't report a result type for the call.
Fix: Add -- @col what: string | number above the query.
Example: examples/errors/annotate-mixed
HSQL6010 — annotate-arms
Message: HSQL6010: column x: its UNION, INTERSECT or EXCEPT arms have different types; add -- @col x: <type>
Example output: src/query.sql: HSQL6010: column title: its UNION, INTERSECT or EXCEPT arms have different types; add -- @col title: <type>
File: src/query.sql
SELECT title FROM books UNION SELECT price_cents FROM booksThe two UNION branches return different types—string (title) and number (price_cents)—and SQLite doesn't determine a single column type for the union.
Fix: Add -- @col title: string | number above the query, or ensure both branches return the same type.
Example: examples/errors/annotate-arms
HSQL7001 — part-malformed
Message: HSQL7001: malformed mark: write /*if :p*/, /*on :f*/, /*off :f*/, /*sort :p a = x | b = y*/ or /*end*/
Example output: src/query.sql: HSQL7001: malformed mark: write /*if :p*/, /*on :f*/, /*off :f*/, /*sort :p a = x | b = y*/ or /*end*/
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*if :max extra*/ AND price_cents <= :max /*end*/The block comment /*if :max extra*/ looks like a hyper-sql directive, but an /*if*/ block only takes a single :param name.
Fix: Remove the extra token: /*if :max*/ AND price_cents <= :max /*end*/.
Example: examples/errors/part-malformed
HSQL7002 — part-nested
Message: HSQL7002: a mark inside a part: marks do not nest, so close the part with /*end*/ first
Example output: src/query.sql: HSQL7002: a mark inside a part: marks do not nest, so close the part with /*end*/ first
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*if :a*/ AND title = :a /*if :b*/ AND price_cents <= :b /*end*/ /*end*/An optional SQL block opens inside another optional block, but hyper-sql doesn't allow nested blocks.
Fix: Close the first block before opening the next: /*if :a*/ AND title = :a /*end*/ /*if :b*/ AND price_cents <= :b /*end*/.
Example: examples/errors/part-nested
HSQL7003 — part-stray-end
Message: HSQL7003: /*end*/ closes no part: remove it, or open the part with /*if :p*/
Example output: src/query.sql: HSQL7003: /*end*/ closes no part: remove it, or open the part with /*if :p*/
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*end*/There's an /*end*/ comment with no matching opening /*if*/, /*on*/, /*off*/, or /*sort*/ block.
Fix: Remove the stray /*end*/, or add the opening directive before it.
Example: examples/errors/part-stray-end
HSQL7004 — part-unclosed
Message: HSQL7004: /*if :p*/ has no /*end*/: add /*end*/ after the last token of the part
Example output: src/query.sql: HSQL7004: /*if :max*/ has no /*end*/: add /*end*/ after the last token of the part
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*if :max*/ AND price_cents <= :maxThe optional block started by /*if :max*/ is missing its closing /*end*/.
Fix: Close the block right after its condition: /*if :max*/ AND price_cents <= :max /*end*/.
Example: examples/errors/part-unclosed
HSQL7005 — part-select
Message: HSQL7005: /*if :p*/ is around a select item: use a flag, /*on :f*/ … /*end*/, or write two named statements
Example output: src/query.sql: HSQL7005: /*if :n*/ is around a select item: use a flag, /*on :f*/ … /*end*/, or write two named statements
File: src/query.sql
-- @param n: number
-- @col bumped: number
SELECT title /*if :n*/, price_cents + :n AS bumped /*end*/ FROM booksAn /*if :p*/ block can't wrap a SELECT item, because omitting it would change the returned row shape without typed overloads.
Fix: Use a boolean flag (/*on :bumped*/, price_cents AS bumped /*end*/) to generate typed overloads, or split into two named queries.
Example: examples/errors/part-select
HSQL7006 — part-elsewhere
Message: HSQL7006: /*if :p*/ stands where no part may: it is one AND term of a WHERE or HAVING clause, one item of a SET list, or one INSERT column with its value; for other text use a flag, /*on :f*/ … /*end*/
Example output: src/query.sql: HSQL7006: /*if :n*/ stands where no part may: it is one AND term of a WHERE or HAVING clause, one item of a SET list, or one INSERT column with its value; for other text use a flag, /*on :f*/ … /*end*/
File: src/query.sql
-- @param n: number
SELECT title FROM books /*if :n*/ LIMIT :n /*end*//*if :p*/ can only wrap a WHERE/HAVING AND condition, a SET assignment, or an INSERT column/value pair—not clauses like LIMIT.
Fix: Use a boolean flag instead: /*on :limited*/ LIMIT 10 /*end*/.
Example: examples/errors/part-elsewhere
HSQL7007 — part-first-term
Message: HSQL7007: /*if :p*/ must follow another term: write WHERE 1 = 1 /*if :p*/ AND … /*end*/ (HAVING 1 = 1 for HAVING), and keep the WHERE word outside the part
Example output: src/query.sql: HSQL7007: /*if :p*/ must follow another term: write WHERE 1 = 1 /*if :p*/ AND … /*end*/ (HAVING 1 = 1 for HAVING), and keep the WHERE word outside the part
File: src/query.sql
SELECT title FROM books /*if :p*/ WHERE title = :p /*end*/The /*if :p*/ block wraps the WHERE keyword itself, which would leave invalid SQL or break subsequent filters when omitted.
Fix: Keep WHERE outside the block with an always-true anchor: WHERE 1 = 1 /*if :p*/ AND title = :p /*end*/.
Example: examples/errors/part-first-term
HSQL7008 — part-trailing-and
Message: HSQL7008: /*if :p*/ ends with AND: move the AND to the front, /*if :p*/ AND … /*end*/
Example output: src/query.sql: HSQL7008: /*if :p*/ ends with AND: move the AND to the front, /*if :p*/ AND … /*end*/
File: src/query.sql
SELECT title FROM books WHERE 1 = 1 AND /*if :p*/ title = :p AND /*end*/ price_cents > 0The optional block puts AND at the end instead of the front, which breaks syntax when it's the last condition.
Fix: Put AND at the start of the block: WHERE price_cents > 0 /*if :p*/ AND title = :p /*end*/.
Example: examples/errors/part-trailing-and
HSQL7009 — part-not-term
Message: HSQL7009: /*if :p*/ must be one whole AND term: start the part with AND
Example output: src/query.sql: HSQL7009: /*if :n*/ must be one whole AND term: start the part with AND
File: src/query.sql
-- @param n: number
SELECT title FROM books WHERE price_cents > 0 /*if :n*/ + :n /*end*/A WHERE /*if*/ block must be a self-contained AND condition, but + :n mutates the expression right before it.
Fix: Wrap a complete AND condition instead: /*if :n*/ AND price_cents > :n /*end*/.
Example: examples/errors/part-not-term
HSQL7010 — part-or-part
Message: HSQL7010: /*if :p*/ would change how the other terms bind with OR: put the OR terms in brackets, /*if :p*/ AND (a OR b) /*end*/
Example output: src/query.sql: HSQL7010: /*if :p*/ would change how the other terms bind with OR: put the OR terms in brackets, /*if :p*/ AND (a OR b) /*end*/
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*if :p*/ OR title = :p /*end*/Starting an optional block with OR would alter operator precedence across the rest of the WHERE clause.
Fix: Write it as an AND block with any OR logic parenthesized inside: /*if :p*/ AND (a OR b) /*end*/.
Example: examples/errors/part-or-part
HSQL7011 — part-or-before
Message: HSQL7011: /*if :p*/ follows an OR in the same clause, so its AND would bind to the last term only: put the OR terms in brackets before it, WHERE (a OR b) /*if :p*/ AND … /*end*/
Example output: src/query.sql: HSQL7011: /*if :p*/ follows an OR in the same clause, so its AND would bind to the last term only: put the OR terms in brackets before it, WHERE (a OR b) /*if :p*/ AND … /*end*/
File: src/query.sql
SELECT title FROM books WHERE title = 'a' OR title = 'b' /*if :p*/ AND price_cents <= :p /*end*/Because AND binds tighter than OR, putting an optional AND block directly after an unparenthesized OR would only apply to title = 'b'.
Fix: Parenthesize the OR expression before the block: WHERE (title = 'a' OR title = 'b') /*if :p*/ AND price_cents <= :p /*end*/.
Example: examples/errors/part-or-before
HSQL7012 — part-not-whole
Message: HSQL7012: /*if :p*/ must be one whole term: its brackets must close inside it, and it must not run into the next clause (ORDER BY, GROUP BY, LIMIT, UNION, …)
Example output: src/query.sql: HSQL7012: /*if :p*/ must be one whole term: its brackets must close inside it, and it must not run into the next clause (ORDER BY, GROUP BY, LIMIT, UNION, …)
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*if :p*/ AND price_cents <= :p ORDER BY title /*end*/The optional block extends past the WHERE condition into the ORDER BY clause, violating the rule that each block must be one self-contained term.
Fix: Close the block before ORDER BY: /*if :p*/ AND price_cents <= :p /*end*/ ORDER BY title.
Example: examples/errors/part-not-whole
HSQL7013 — part-outside
Message: HSQL7013: parameter p is used in /*if :p*/ and outside it: use it in one place
Example output: src/query.sql: HSQL7013: parameter :max is used in /*if :min*/ and outside it: use it in one place
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*if :min*/ AND price_cents >= :min AND price_cents <= :max /*end*/ AND price_cents <> :max:max is referenced both inside an optional block and outside it, which breaks when the block is omitted.
Fix: Use :max in only one place, or introduce a second parameter name for the other use.
Example: examples/errors/part-outside
HSQL7014 — part-no-use
Message: HSQL7014: /*if :p*/ does not use its parameter: write the parameter in the part, or use a flag, /*on :f*/ … /*end*/
Example output: src/query.sql: HSQL7014: /*if :p*/ does not use its parameter: write the parameter in the part, or use a flag, /*on :f*/ … /*end*/
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*if :p*/ AND title <> '' /*end*/The block opens with /*if :p*/, but :p never appears inside the block.
Fix: Reference :p inside the block, or switch to a boolean flag (/*on :f*/ ... /*end*/) if no value is needed.
Example: examples/errors/part-no-use
HSQL7015 — part-set-item
Message: HSQL7015: /*if :p*/ must be one whole SET item with its comma: write SET /*if :p*/ c = :p, /*end*/ updated = now()
Example output: src/query.sql: HSQL7015: /*if :t*/ must be one whole SET item with its comma: write SET /*if :p*/ c = :p, /*end*/ updated = now()
File: src/query.sql
UPDATE books SET price_cents = :c /*if :t*/ , title = :t, meta = 'x' /*end*/ WHERE isbn = :isbnEach optional block in an UPDATE ... SET clause must wrap a single column assignment with its comma, but this block wraps two.
Fix: Give each optional assignment its own block: SET price_cents = :c /*if :t*/, title = :t /*end*/.
Example: examples/errors/part-set-item
HSQL7016 — part-set-alone
Message: HSQL7016: /*if :p*/ leaves a comma with no item beside it in some form: keep an item outside every part after it when its comma is last, before it when its comma is first, SET /*if :p*/ c = :p, /*end*/ updated = now()
No example: If every optional assignment in a SET clause is omitted, the resulting SQL has an empty SET, so hyper-sql pull reports the database's syntax error first.
HSQL7017 — part-insert-item
Message: HSQL7017: /*if :p*/ must be one item of the list with its comma in front: (a /*if :c*/, c /*end*/) VALUES (:a /*if :c*/, :c /*end*/)
Example output: src/query.sql: HSQL7017: /*if :n*/ must be one item of the list with its comma in front: (a /*if :c*/, c /*end*/) VALUES (:a /*if :c*/, :c /*end*/) / src/query.sql: HSQL7017: /*if :n*/ must be one item of the list with its comma in front: (a /*if :c*/, c /*end*/) VALUES (:a /*if :c*/, :c /*end*/)
File: src/query.sql
INSERT INTO orders (isbn, quantity /*if :n*/ , note, id /*end*/) VALUES (:isbn, :q /*if :n*/ , :n, :n2 /*end*/)Each optional block in an INSERT must wrap a single column (and its matching value) with a leading comma, but this block wraps two.
Fix: Wrap each optional column/value pair in its own block: (isbn, quantity /*if :n*/, note /*end*/) VALUES (:isbn, :q /*if :n*/, :n /*end*/).
Example: examples/errors/part-insert-item
HSQL7018 — part-insert-first
Message: HSQL7018: /*if :p*/ has no item that is always on before it in its list, so its comma would stand first: write the first column and its value outside every part
No example: If every optional column in an INSERT is omitted, the column list is empty, so hyper-sql pull reports the database's syntax error first.
HSQL7019 — part-insert-pair
Message: HSQL7019: /*if :p*/ needs the part with the same name at the same place in the other list: (a /*if :c*/, c /*end*/) VALUES (:a /*if :c*/, :c /*end*/)
Example output: src/query.sql: HSQL7019: /*if :n*/ needs the part with the same name at the same place in the other list: (a /*if :c*/, c /*end*/) VALUES (:a /*if :c*/, :c /*end*/) / src/query.sql: HSQL7019: /*if :m*/ needs the part with the same name at the same place in the other list: (a /*if :c*/, c /*end*/) VALUES (:a /*if :c*/, :c /*end*/)
File: src/query.sql
INSERT INTO orders (isbn, quantity /*if :n*/ , note /*end*/) VALUES (:isbn, :q /*if :m*/ , :m /*end*/)An optional INSERT column and its corresponding value must share the same /*if :name*/ parameter, but here the column uses :n while the value uses :m.
Fix: Use the same parameter name in both lists: /*if :n*/, note /*end*/ and /*if :n*/, :n /*end*/.
Example: examples/errors/part-insert-pair
HSQL7020 — part-insert-rows
Message: HSQL7020: /*if :p*/ is in a VALUES list of more than one row: an optional column needs a single-row VALUES, so write one statement for each row
Example output: src/query.sql: HSQL7020: /*if :n*/ is in a VALUES list of more than one row: an optional column needs a single-row VALUES, so write one statement for each row / src/query.sql: HSQL7020: /*if :n*/ is in a VALUES list of more than one row: an optional column needs a single-row VALUES, so write one statement for each row / src/query.sql: HSQL7019: /*if :n*/ needs the part with the same name at the same place in the other list: (a /*if :c*/, c /*end*/) VALUES (:a /*if :c*/, :c /*end*/)
File: src/query.sql
INSERT INTO orders (isbn /*if :n*/ , note /*end*/) VALUES (:a /*if :n*/ , :n /*end*/), (:b /*if :n*/ , :n /*end*/)Optional INSERT columns only work with single-row VALUES because each column block must pair with exactly one value block; multi-row VALUES creates multiple value blocks for one column.
Fix: Split the insert into single-row statements, or omit the optional column block.
Example: examples/errors/part-insert-rows
HSQL7021 — part-merge
Message: HSQL7021: /*if :p*/ is in a MERGE, which takes no optional part: write the MERGE without it, or one named MERGE statement for each form
Example output: src/query.sql: HSQL7021: /*if :min*/ is in a MERGE, which takes no optional part: write the MERGE without it, or one named MERGE statement for each form
File: src/query.sql
MERGE INTO stock s
USING incoming i ON s.sku = i.sku /*if :min*/ AND i.qty >= :min /*end*/
WHEN MATCHED THEN UPDATE SET qty = i.qtyOptional SQL blocks (/*if*/, /*on*/, /*off*/, /*sort*/) aren't supported inside MERGE statements because changing branches alters which columns and rows are affected.
Fix: Write the MERGE in full without optional blocks, or define separate -- @name MERGE statements for each variant.
Example: examples/errors/part-merge
HSQL7022 — part-no-default
Message: HSQL7022: /*if :p*/: column c is NOT NULL and has no default, so it cannot be left out: write it outside the part, or give the column a DEFAULT in schema.sql and run hyper-sql pull
Example output: src/query.sql: HSQL7022: /*if :q*/: column quantity is NOT NULL and has no default, so it cannot be left out: write it outside the part, or give the column a DEFAULT in schema.sql and run hyper-sql pull
File: src/query.sql
INSERT INTO orders (isbn /*if :q*/ , quantity /*end*/) VALUES (:isbn /*if :q*/ , :q /*end*/)quantity is NOT NULL with no DEFAULT, so omitting it from an INSERT would fail at runtime.
Fix: Move quantity outside the optional block, or add a DEFAULT in schema.sql and re-run hyper-sql pull.
Example: examples/errors/part-no-default
HSQL7023 — part-sort-form
Message: HSQL7023: /*sort :p a = x*/ must list its choices as name = SQL, split by |: /*sort :p newest = t.created_at DESC | title = t.title, t.id*/ t.created_at DESC /*end*/ (a lone | of the SQL goes in brackets)
Example output: src/query.sql: HSQL7023: /*sort :s …*/ must list its choices as name = SQL, split by |: /*sort :p newest = t.created_at DESC | title = t.title, t.id*/ t.created_at DESC /*end*/ (a lone | of the SQL goes in brackets)
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*sort :s newest*/ AND 1 = 1 /*end*/A /*sort*/ directive must define name = SQL pairs separated by |, but this one only writes newest with no = SQL expression.
Fix: Provide valid choices inside ORDER BY: /*sort :s newest = title DESC | oldest = title*/ title DESC /*end*/.
Example: examples/errors/part-sort-form
HSQL7024 — part-sort-duplicate
Message: HSQL7024: /*sort :p a = x | a = y*/ has two choices named a: give each choice its own name
Example output: src/query.sql: HSQL7024: /*sort :s …*/ has two choices named a: give each choice its own name
File: src/query.sql
SELECT title FROM books ORDER BY /*sort :s a = title | a = isbn*/ title /*end*/Two choices in the same /*sort*/ directive share the name a, so callers couldn't distinguish between them.
Fix: Give every sort choice a unique name: /*sort :s title = title | isbn = isbn*/.
Example: examples/errors/part-sort-duplicate
HSQL7025 — part-sort-choices
Message: HSQL7025: p is the name of two sorts with different choices: give each its own name, or write the same choices
Example output: src/query.sql: HSQL7025: s is the name of two sorts with different choices: give each its own name, or write the same choices
File: src/query.sql
WITH x AS (SELECT title FROM books ORDER BY /*sort :s a = title | b = isbn*/ title /*end*/ LIMIT 5) SELECT title FROM x ORDER BY /*sort :s a = title | c = title DESC*/ title /*end*/Two /*sort :s ...*/ directives reuse the same parameter name s with different choice lists, but a parameter can only have one union type.
Fix: Give each sort directive its own parameter name, or use identical choice lists in both.
Example: examples/errors/part-sort-choices
HSQL7026 — part-sort-place
Message: HSQL7026: /*sort :p a = x*/ stands outside an ORDER BY: write ORDER BY /*sort :p a = x | b = y*/ x /*end*/
Example output: src/query.sql: HSQL7026: /*sort :s …*/ stands outside an ORDER BY: write ORDER BY /*sort :p a = x | b = y*/ x /*end*/
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 AND /*sort :s a = title | b = isbn*/ title /*end*/ <> ''This /*sort*/ directive is placed inside a WHERE clause, but /*sort*/ is only valid inside ORDER BY.
Fix: Move it into ORDER BY: ORDER BY /*sort :s a = title | b = isbn*/ title /*end*/.
Example: examples/errors/part-sort-place
HSQL7027 — part-sort-drift
Message: HSQL7027: /*sort :p a = x*/ must hold its first choice between the marks, so that the file still runs as plain SQL: write x
Example output: src/query.sql: HSQL7027: /*sort :s …*/ must hold its first choice between the marks, so that the file still runs as plain SQL: write title
File: src/query.sql
SELECT title FROM books ORDER BY /*sort :s a = title | b = isbn*/ isbn /*end*/The fallback SQL between /*sort*/ and /*end*/ (isbn) doesn't match the first choice (title), so running the .sql file directly wouldn't match its default sort.
Fix: Put the first choice between the comments: /*sort :s a = title | b = isbn*/ title /*end*/.
Example: examples/errors/part-sort-drift
HSQL7028 — part-mark-value
Message: HSQL7028: f is the name of /*on :f*/, which has no value: take :f out of the SQL, or give the value its own name
Example output: src/query.sql: HSQL7028: f is the name of /*on :f*/ or /*off :f*/, which has no value: take :f out of the SQL, or give the value its own name
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*on :f*/ AND 1 = 1 /*end*/ AND title = :ff is declared as a boolean flag (/*on :f*/), which toggles SQL on or off and doesn't bind a SQL parameter value, yet :f is also used as a value in the query.
Fix: Remove :f from the SQL expression, or give the value parameter a separate name.
Example: examples/errors/part-mark-value
HSQL7029 — part-two-roles
Message: HSQL7029: p is the name of marks of two kinds (a value /*if :p*/, a flag /*on :p*/, a sort /*sort :p …*/): give each its own name
Example output: src/query.sql: HSQL7029: p is the name of marks of two kinds (a value /*if :p*/, a flag /*on :p*/, a sort /*sort :p …*/): give each its own name
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*on :p*/ AND 1 = 1 /*end*/ ORDER BY /*sort :p a = title | b = isbn*/ title /*end*/The same parameter name p is used for both a boolean flag (/*on :p*/) and a sort directive (/*sort :p ...*/), which conflict in type.
Fix: Give each directive its own parameter name.
Example: examples/errors/part-two-roles
HSQL7030 — part-too-many-flags
Message: HSQL7030: flag f is one flag too many: a statement has at most 3 flags, one form for each combination, so split it into named statements
Example output: src/query.sql:1:131: HSQL7030: flag d is one flag too many: a statement has at most 3 flags, one form for each combination, so split it into named statements
File: src/query.sql
SELECT title FROM books WHERE price_cents > 0 /*on :a*/ AND 1 = 1 /*end*/ /*on :b*/ AND 2 = 2 /*end*/ /*on :c*/ AND 3 = 3 /*end*/ /*on :d*/ AND 4 = 4 /*end*/Because hyper-sql pull prepares every flag combination (2^N variants), a statement can have at most 3 flags—adding a fourth flag (d) exceeds the limit.
Fix: Split the query into multiple named statements instead.
Example: examples/errors/part-too-many-flags
HSQL8001 — pull-no-schema
Message: HSQL8001: db/schema.sql not found: set "schema" to the file that holds the DDL
Example output: HSQL8001: db/schema.sql not found: set "schema" to the file that holds the DDL
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": { "dialect": "sqlite", "schema": "db/schema.sql" } }],
"include": ["main.ts", "src"]
}Your configuration points "schema" at db/schema.sql, but that file doesn't exist.
Fix: Set "schema" in tsconfig.json to the actual path of your schema DDL file.
Example: examples/errors/pull-no-schema
HSQL8002 — pull-schema-error
Message: HSQL8002: schema.sql: near "TABL": syntax error
Example output: HSQL8002: schema.sql: near "TABL": syntax error
File: schema.sql
CREATE TABL books (
isbn TEXT PRIMARY KEY,
title TEXT NOT NULL
) STRICT;SQLite rejected schema.sql with a syntax error (CREATE TABL instead of CREATE TABLE), so hyper-sql pull aborted without updating sql.lock.
Fix: Fix the DDL syntax in schema.sql and run hyper-sql pull again.
Example: examples/errors/pull-schema-error
HSQL8003 — pull-not-strict
Message: HSQL8003: t: not STRICT; add STRICT, or set "sqliteStrict": false
Example output: HSQL8003: books: not STRICT; add STRICT, or set "sqliteStrict": false
File: schema.sql
CREATE TABLE books (
isbn TEXT PRIMARY KEY,
title TEXT NOT NULL
);books in schema.sql isn't declared STRICT, so SQLite won't enforce its column types on writes. By default, hyper-sql pull refuses non-STRICT tables so TypeScript types stay trustworthy.
Fix: Add STRICT after the closing parenthesis of CREATE TABLE books (...), or set "sqliteStrict": false in your options.
Example: examples/errors/pull-not-strict
HSQL8004 — pull-query-error
Message: HSQL8004: no such column: x
Example output: src/query.sql:1:1: HSQL8004: no such column: titel
File: src/query.sql
SELECT titel FROM booksSQLite failed to prepare the query because books has no column named titel. hyper-sql pull stops without modifying sql.lock.
Fix: Fix the column name (SELECT title FROM books) and re-run hyper-sql pull.
Example: examples/errors/pull-query-error
HSQL8005 — pull-param-conflict
Message: HSQL8005: parameter :x is text in one form and int4 in another: give it one type, for example with a cast
Example output: src/query.sql:1:1: HSQL8005: parameter :key is text in one form and int4 in another: give it one type, for example with a cast
File: src/query.sql
SELECT code FROM flights WHERE 1 = 1 /*on :by_id*/ AND id = :key /*end*/ /*off :by_id*/ AND code = :key /*end*/Across two variants of this dynamic query, :key is inferred as an integer in one branch and text in the other, but a parameter must have a single consistent type.
Fix: Ensure :key compares against the same type in every variant, or split it into two parameters (such as :key and :code).
Example: examples/errors/pull-param-conflict
HSQL8006 — pull-not-in-schema
Message: HSQL8006: t is not in schema.sql: the lock holds the tables of schema.sql only, so add its CREATE TABLE there
Example output: src/query.sql:1:1: HSQL8006: pg_class is not in schema.sql: the lock holds the tables of schema.sql only, so add its CREATE TABLE there
File: src/query.sql
SELECT relname FROM pg_classThe query reads from pg_class, which isn't defined in schema.sql. sql.lock only tracks tables and views declared in your schema file.
Fix: Add the table definition to schema.sql, or run system catalog queries directly on your raw database driver.
Example: examples/errors/pull-not-in-schema
HSQL8007 — pull-transaction
Message: HSQL8007: BEGIN controls the transaction that the pull rolls back: take it out of the schema file
Example output: schema.sql:1:1: HSQL8007: BEGIN controls the transaction that the pull rolls back: take it out of the schema file
File: schema.sql
BEGIN;
CREATE TABLE flights (
id integer PRIMARY KEY,
code text NOT NULL,
departs_at timestamptz NOT NULL,
seats integer NOT NULL
);
CREATE TABLE passengers (
id integer PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE bookings (
id integer PRIMARY KEY,
flight_id integer NOT NULL REFERENCES flights (id),
passenger_id integer NOT NULL REFERENCES passengers (id)
);schema.sql contains a BEGIN statement. Because hyper-sql pull applies your schema inside its own rolled-back transaction on Postgres, explicit transaction statements inside schema.sql interfere with that rollback.
Fix: Remove BEGIN, COMMIT, and ROLLBACK statements from schema.sql.
Example: examples/errors/pull-transaction
HSQL8008 — pull-no-sqlite
Message: HSQL8008: this host has no SQLite: run hyper-sql pull with Node 24 or later
No example: Occurs on Node versions before Node 24 that don't include node:sqlite. Upgrade to Node 24 or later.
HSQL8009 — pull-no-database-url
Message: HSQL8009: DATABASE_URL is not set: with "dialect": "postgres" the pull connects to the database that it names (postgres://user:password@host:port/database?sslmode=disable|require|verify-full)
No example: Occurs when running hyper-sql pull on a Postgres project without DATABASE_URL set in your environment. Set DATABASE_URL to your connection string.
HSQL8010 — pull-indeterminate-type
Message: HSQL8010: could not determine data type of parameter $1 / Postgres cannot settle the type of a parameter here: write the filter as a part, /*if :p*/ AND col = :p /*end*/, or cast the parameter, :p::type
Example output: src/query.sql:1:33: HSQL8010: could not determine data type of parameter $1 / Postgres cannot settle the type of a parameter here: write the filter as a part, /*if :p*/ AND col = :p /*end*/, or cast the parameter, :p::type
File: src/query.sql
SELECT code FROM flights WHERE (:id IS NULL OR id = :id)Postgres infers a parameter's type from its first occurrence. In :id IS NULL OR id = :id, :id IS NULL gives Postgres no type information, so hyper-sql pull fails and suggests two fixes (SQLite handles this form automatically).
Fix: Use an optional block (/*if :id*/ AND id = :id /*end*/) so the filter is omitted when id is undefined, or cast the parameter explicitly ((:id::int IS NULL OR id = :id)).
Example: examples/errors/pull-indeterminate-type
HSQL9001 — option-not-object
Message: HSQL9001: options must be an object: { "dialect": "sqlite" | "postgres", "schema": "db/schema.sql", "lock": "sql.lock" }
Example output: tsconfig.json: HSQL9001: options must be an object: { "dialect": "sqlite" | "postgres", "schema": "db/schema.sql", "lock": "sql.lock" }
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": "sqlite" }],
"include": ["main.ts", "src"]
}The "options" field of hyper-sql's contentMappers entry in tsconfig.json is set to the string "sqlite" instead of an options object.
Fix: Write options as an object: "options": { "dialect": "sqlite", "schema": "schema.sql" }.
Example: examples/errors/option-not-object
HSQL9002 — option-dialect
Message: HSQL9002: dialect is required and must be "sqlite" or "postgres"
Example output: tsconfig.json: dialect: HSQL9002: dialect is required and must be "sqlite" or "postgres"
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": { "schema": "schema.sql" } }],
"include": ["main.ts", "src"]
}The options object in tsconfig.json is missing "dialect", so hyper-sql doesn't know whether to target SQLite or Postgres.
Fix: Add "dialect": "sqlite" (or "postgres") to your hyper-sql options.
Example: examples/errors/option-dialect
HSQL9003 — option-schema
Message: HSQL9003: schema must be a file path, for example "db/schema.sql"
Example output: tsconfig.json: schema: HSQL9003: schema must be a file path, for example "db/schema.sql"
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": { "dialect": "sqlite", "schema": 5 } }],
"include": ["main.ts", "src"]
}The "schema" option is set to 5, but it must be a file path pointing to your schema DDL file.
Fix: Set "schema" to a path string, such as "schema": "schema.sql".
Example: examples/errors/option-schema
HSQL9004 — option-lock
Message: HSQL9004: lock must be a file path, for example "sql.lock"
Example output: tsconfig.json: lock: HSQL9004: lock must be a file path, for example "sql.lock"
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": { "dialect": "sqlite", "schema": "schema.sql", "lock": 5 } }],
"include": ["main.ts", "src"]
}The "lock" option is set to 5, but it must be a file path where hyper-sql pull reads and writes the lock file.
Fix: Set "lock": "sql.lock", or omit the option to use the default path.
Example: examples/errors/option-lock
HSQL9005 — option-unknown
Message: HSQL9005: unknown option: the options are dialect, schema, lock, sqliteStrict and types
Example output: tsconfig.json: journal: HSQL9005: unknown option: the options are dialect, schema, lock, sqliteStrict and types
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": { "dialect": "sqlite", "schema": "schema.sql", "journal": "wal" } }],
"include": ["main.ts", "src"]
}The options object includes an unrecognized key ("journal"). hyper-sql only accepts dialect, schema, lock, sqliteStrict, and types.
Fix: Remove "journal" or fix its spelling to one of the supported option names.
Example: examples/errors/option-unknown
HSQL9006 — option-types
Message: HSQL9006: types must be an object that sets int8 to "bigint" or "number" and timestamp to "string" or "Date", for example { "int8": "number", "timestamp": "Date" }
Example output: tsconfig.json: types: HSQL9006: types must be an object that sets int8 to "bigint" or "number" and timestamp to "string" or "Date", for example { "int8": "number", "timestamp": "Date" }
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": { "dialect": "sqlite", "schema": "schema.sql", "types": { "int8": "int" } } }],
"include": ["main.ts", "src"]
}The "types" option only accepts "int8": "bigint" | "number" and "timestamp": "string" | "Date", so "int" isn't valid.
Fix: Use a supported value, such as "types": { "int8": "number" }.
Example: examples/errors/option-types
HSQL9007 — option-sqlite-strict
Message: HSQL9007: sqliteStrict must be true or false: false lets the SQLite pull accept a table that is not STRICT
Example output: tsconfig.json: sqliteStrict: HSQL9007: sqliteStrict must be true or false: false lets the SQLite pull accept a table that is not STRICT
File: tsconfig.json
{
"compilerOptions": { "target": "ES2022", "module": "NodeNext", "strict": true, "noEmit": true, "allowImportingTsExtensions": true, "types": [] },
"contentMappers": [{ "package": "@exprtlabs/hyper-sql", "extensions": [".sql"], "options": { "dialect": "sqlite", "schema": "schema.sql", "sqliteStrict": "no" } }],
"include": ["main.ts", "src"]
}The "sqliteStrict" option is set to "no", but it expects a boolean (true by default rejects non-STRICT SQLite tables; false allows them).
Fix: Set "sqliteStrict": false, or remove the option to keep the default.
Example: examples/errors/option-sqlite-strict