github.com/mitranim/sqlp
Parser and formatter for rewriting foreign code embedded in SQL queries, such as parameter placeholders: `$1` or `:ident`, or code encased in delimiters: `()` `[]` `{}`. It supports the following SQL features: • ” : single quotes. • "" : double quotes. • “ : grave quotes (non-standard). • -- : line comments. • /* : block comments. • :: : Postgres-style cast operator (non-standard). In addition, it supports the following: • () : content in parens. • [] : content in brackets. • {} : content in braces. • $1 $2 ... : ordinal parameter placeholders. • :identifier : named parameter placeholders. Supporting SQL quotes and comments allows us to correctly ignore text inside special delimiters that happens to be part of a string, quoted identifier, or comment. This library supports incremental parsing token by token, via `Tokenizer`. It also lets you convert a sequence of tokens into a fully-built AST via `Parser`. Choose the approach that better suits your use case. Oversimplified example: The AST now looks like this:
proxy.golang.org
v0.3.0
almost 3 years ago
7
1
1
Links
| Registry | proxy.golang.org |
| Source | Repository |
| Docs | Documentation |
| JSON API | View JSON |
| CodeMeta | codemeta.json |
Package Details
| PURL |
pkg:golang/github.com/mitranim/sqlp
spec |
| License | Unlicense |
| Namespace | github.com/mitranim |
| First Release | over 5 years ago |
| Last Synced | 22 days ago |
Repository
| Stars | 1 on GitHub |
| Forks | 0 on GitHub |