Documentation
¶
Overview ¶
Package sqllex reads rendered SQL back into tokens under one dialect's quoting rules. It exists for tests: a fuzz property checked against an independent reading of the output catches what a check written against the code that produced it would share.
It knows quoting and nothing else. Quoted identifiers and string literals are decoded; every other run of bytes between spaces and quotes is one Other token, kept verbatim.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dialect ¶
type Dialect int
Dialect selects the quoting rules Lex applies.
const ( // ANSI is PostgreSQL and SQLite: "identifiers" with "" doubling, and // 'strings' with ” doubling, where a backslash is an ordinary byte. ANSI Dialect = iota // MySQL has `identifiers` with “ doubling, and 'strings' or "strings" // (the default sql_mode, without ANSI_QUOTES) with the quote doubled or // backslash escaped. \x decodes to x for every x. That is exact for the // escaping gosbee emits (\\ and ”), but not for MySQL in general, which // keeps the backslash in \% and \_ and reads \n, \0 and \Z as control bytes. // Lex reads bytes, so it cannot model a multibyte client charset such as // GBK, where a lead byte can swallow an escaping backslash. MySQL )
Click to show internal directories.
Click to hide internal directories.