Documentation
¶
Overview ¶
Package postgres parses PostgreSQL statements into github.com/aita/sqlkit/sql queries. It is the PostgreSQL frontend for github.com/aita/sqlkit/sqlparse, backed by the real PostgreSQL grammar (libpg_query): it parses and deparses through go-pgquery, which runs libpg_query as a WebAssembly module on the pure Go wazero runtime, and reuses the AST types from pg_query_go.
It lives in its own module so the parser dependency tree stays isolated from callers that only need the sqlparse abstraction or the sql package.
q, err := postgres.ParseOne("SELECT id FROM users WHERE active")
text, args, err := q.ToSQL(sql.PostgreSQLDialect{})
Limitations ¶
See the github.com/aita/sqlkit/sqlparse package docs for the limitations common to every frontend (partial mapping with a deparsed RawSQL fallback, loss of comments and formatting on that fallback, and so on). Backend-specific notes:
Pure Go. go-pgquery compiles libpg_query to WebAssembly and runs it on the wazero runtime, so this module builds without cgo or a C toolchain (it still depends on pg_query_go for the AST types, whose cgo entry points are unused). WebAssembly execution is several times slower than calling libpg_query through cgo, which is acceptable for parsing/import workloads but not for parsing very high query volumes online.
Statement positions come from the parse result's statement locations, so each Query's position points at its start in the source text.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.