Moved to https://github.com/mitranim/sqlb. This repo is usable but frozen.
SQL Parse: parser and formatter for rewriting foreign code embedded in SQL queries, such as parameter placeholders: $1
or :ident
, or code encased in delimiters: ()
[]
{}
. Anything the parser doesn't recognize is preserved as text.
API docs: https://pkg.go.dev/github.com/mitranim/sqlp.
Renamed method .Append
in various types to .AppendTo
for consistency with other libraries.
Various optimizations.
-
Added
Type
,Region
,Token
for use by the tokenizer; see below. -
Tokenization is now allocation-free and around x2 faster in benchmarks. Instead of generating
Node
instances, the tokenizer generates stack-allocatedToken
instances.
Added NodeWhitespace
. This is emitted for any non-zero amount of whitespace. NodeText
now contains only non-whitespace. The performance impact seems negligible.
Support incremental parsing via Tokenizer
. Added a few utility functions related to tree traversal. Minor breaking renaming.
Added missing (*Error).Unwrap
.
Replaced []rune
with string
. When parsing, we treat the input string as UTF-8, decoding on the fly.
First tagged release.
I'm receptive to suggestions. If this library almost satisfies you but needs changes, open an issue or chat me up. Contacts: https://mitranim.com/#contacts