sqlite

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

dialect/sqlite — the SQLite dialect

Placeholders (?), identifier quoting (double quotes), and the capabilities this engine has.

It imports render and nothing else — which is exactly what a dialect written in another repository imports. That is the point of the layout: adding SQLite and adding an engine nobody has written yet are the same act, and TestDialects_ImportOnlyRender reads this package's import list and fails on anything else.

It declares SupportsReturning and SupportsLikeEscape. The second is worth reading carefully, because the distinction is easy to get backwards: SQLite accepts an explicit ESCAPE clause, which is what the capability reports, but it has no default escape character the way Postgres and MySQL do. So expr.Contains must write ESCAPE out rather than relying on a backslash — a pattern that assumed the backslash would match zero rows here, silently, and look like it worked.

The constructs SQLite spells differently are not here. They live in the engine construct package, because a caller naming the engine it builds for should not have to import several hundred constructs to do it.

Full documentation

docs/dialect/README.md covers all three and how to write a fourth; docs/dialects.md covers what a dialect decides and how a construct fails closed under the wrong one.

Documentation

Overview

Package sqlite is the SQLite dialect: positional placeholders and double-quoted identifiers.

It imports the render layer and nothing else. See the postgres package in this directory for why each dialect is its own package.

The constructs that only SQLite has live in github.com/ubgo/sqlb/sqlite.

Index

Constants

Name is the engine name this dialect reports. Engine packages guard on it.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect struct{}

Dialect renders ? placeholders and double-quoted identifiers.

func (Dialect) Name

func (Dialect) Name() string

Name reports "sqlite".

func (Dialect) Placeholder

func (Dialect) Placeholder(int) string

Placeholder renders ?. SQLite placeholders are positional, so the argument order is the only thing that binds a value to a position.

func (Dialect) QuoteIdent

func (Dialect) QuoteIdent(ident string) string

QuoteIdent double-quotes an identifier, doubling any embedded quote.

func (Dialect) QuoteLiteral

func (Dialect) QuoteLiteral(v any) (string, error)

QuoteLiteral writes v as a SQLite literal that reads back as exactly v.

SQLite has no escape character in string literals at all, so doubling the single quote is the whole rule and a backslash is an ordinary character.

The value set is closed: strings, bools, every integer and float kind, []byte, nil, a pointer to any of those, and named types whose underlying type is one of them. time.Time is deliberately absent. SQLite has no time type, and the modernc driver stores a bound time.Time as Go's String form, "2026-09-01 12:30:45.123456789 +0000 UTC", which it then cannot scan back into a time.Time from a TEXT column; a literal in any other spelling would not compare equal to a bound value, and there is no spelling that is right. A NUL in a string, a NaN or an infinity, and every other type are ErrNotInlinable.

func (Dialect) SupportsLikeEscape

func (Dialect) SupportsLikeEscape() bool

SupportsLikeEscape reports true: SQLite accepts an ESCAPE clause on LIKE.

SQLite has no default escape character, so the clause is not optional: a pattern escaped with backslashes matches nothing without it.

func (Dialect) SupportsReturning

func (Dialect) SupportsReturning() bool

SupportsReturning reports true. SQLite has had RETURNING since 3.35, and the driver in contrib/driver-sqlite is well past that.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL