Documentation
¶
Overview ¶
Package postgres provides a PostgreSQL dialect parser using pg_query_go.
Package postgres provides a PostgreSQL dialect parser using pg_query_go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseViewSQL ¶
ParseViewSQL parses a CREATE VIEW or CREATE MATERIALIZED VIEW statement using pg_query and extracts the view name, schema, SELECT column metadata, and FROM clause table aliases. CREATE OR REPLACE MATERIALIZED VIEW is not valid PostgreSQL and fails at pg_query.Parse.
An unqualified view name resolves to defaultSchema, the schema New gives an unqualified CREATE TABLE (input.schema, PRD §5.5); an empty defaultSchema means "public". Every PostgreSQL view therefore carries a schema, as every table does.
func QualifyFilterIdentifiers ¶
QualifyFilterIdentifiers rewrites every bare column reference inside expr to be qualified with alias. Already-qualified refs (table.column) are left untouched. The expression is parsed as a PostgreSQL WHERE clause and re-emitted via pg_query's deparser, so quoted identifiers, JSONB operators, CAST/CASE/function-call expressions, and string-literal contents are all handled by the upstream parser rather than custom tokenization.
It performs the codegen-time qualification of sub-categorized o2o `filter:` predicates so the JOIN ON clause binds bare identifiers to the relationship target instead of the parent table.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser implements the parser.Parser interface for PostgreSQL DDL. It uses pg_query_go (which wraps libpg_query via CGO) to parse SQL using PostgreSQL's own parser.
func (*Parser) Parse ¶
Parse parses PostgreSQL DDL from sql. It applies the statements one at a time, in file order, as PostgreSQL does: a statement sees the schema the statements before it left, so a table moved or renamed mid-file no longer answers to its old name, and the old name is free for a later CREATE. It can be called multiple times with different files; results accumulate.