Builder methods never return errors. Every problem is recorded and returned by Build (and by
Dialect.QuoteIdent, DialectFor, RecordColumns and InsertColumns). When Build fails it
returns an empty SQL string and no arguments. Only the first error is reported.
Each error is one of the gohan.Err* constants below, often wrapped with detail such as the
offending name. Compare with errors.Is, not ==:
_,_,err:=gohan.Select("id").From("t").Where(gohan.Col("a").ILike("x%")).Build(gohan.SQLite())fmt.Println(err==gohan.ErrUnsupported,errors.Is(err,gohan.ErrUnsupported))fmt.Println(err)// Output:// false true// gohan: not supported by dialect: ILIKE
DialectFor gets an unregistered name, or Build/QuoteIdent gets the zero Dialect{}
ErrInvalidIdentifier
an identifier is empty, has an empty dotted part or a NUL byte; on ClickHouse, contains ?, @, {, } or $ followed by a digit; an alias or USING column is dotted or *; a CTE name or a written column (INSERT/UPDATE/conflict target) is dotted
ErrUnsupported
a clause or feature the dialect lacks: ILIKE (including ContainsFold/HasPrefixFold/HasSuffixFold on Generic), RETURNING, ON CONFLICT, Excluded, UPDATE, the ClickHouse-only clauses; also Final/Sample on a subquery, more than one ArrayJoin/LeftArrayJoin call on a builder, an aliased INSERT/UPDATE table, an aliased ClickHouse DELETE table
the table is missing, empty, or of the wrong type; Select() with neither columns nor From
ErrNeedAlias
a subquery used as a FROM/JOIN source without As(alias)
ErrInvalidColumn
a select-list, GROUP BY or RETURNING item that is neither a string nor an expression; an ORDER BY item that is not a string, Value or Order; a statement builder, TableRef or Subquery passed as a value
ErrNoWhere
UPDATE/DELETE without a WHERE, or with one that is always true, and without All()
ErrInvalidLimit
LIMIT/OFFSET above math.MaxInt64 (not on ClickHouse)
ErrCompoundPart
a UNION member with its own ORDER BY, LIMIT, OFFSET, WITH, SETTINGS, UNION or a row-locking clause
ErrEmptyClause
ArrayJoin/LeftArrayJoin, JoinUsing/LeftJoinUsing with no columns
ErrInvalidSample
Sample ratio outside (0, 1] or not finite; SampleRows(0)
ErrInvalidSetting
a Settings key not matching ^[A-Za-z_][A-Za-z0-9_]*$
ErrTooManyArgs
more bound arguments than the dialect's limit
ErrInvalidLock
ForUpdate/ForShare/etc. combined with Distinct, GroupBy, Having or UNION; SkipLocked/NoWait with no preceding lock clause, or set twice on the same clause
nothing to write: no row source, Rows() with no records, an empty SetMap, FromSelect without Columns, a record with no insertable field, an UPDATE with no assignments, an empty DoUpdate map or DoUpdateExcluded() with no columns
ErrValueCount
a Values row whose length differs from Columns, or Values without Columns
ErrInsertMixed
more than one of Values, Rows, SetMap, FromSelect
ErrConflictTarget
DoUpdate/DoUpdateExcluded without conflict columns
ErrUnknownField
a DoUpdateExcluded column that is not inserted; an IncludeFields/ExcludeFields name that matches no field
ErrDuplicateColumn
a column assigned twice in an UPDATE; see also Records