/**
* Convert a ParsedQuery AST back to SQL string.
*
* When called without options, returns the SQL as a simple string.
* When called with DeparseOptions, applies formatting (pretty-printing, indentation, etc.).
*
* @throws \RuntimeException if deparsing fails
*/
pg_deparse(ParsedQuery $query, ?DeparseOptions $options) : string DSL References
DSL stands for Domain Specific Language. In the case of Flow, the DSL is used to define simple functions that can be used to transform data. Most of those functions are initializing a new instance of a class under the hood since Flow is fully object-oriented. Please look at the examples below to get a better understanding of how to use the DSL functions.
HELPER
/**
* Create DeparseOptions for configuring SQL formatting.
*/
pg_deparse_options() : DeparseOptions /**
* Returns a fingerprint of the given SQL query.
* Literal values are normalized so they won't affect the fingerprint.
*/
pg_fingerprint(string $sql) : ?string /**
* Parse and format SQL query with pretty printing.
*
* This is a convenience function that parses SQL and returns it formatted.
*
* @param string $sql The SQL query to format
* @param null|DeparseOptions $options Formatting options (defaults to pretty-print enabled)
*
* @throws \RuntimeException if parsing or deparsing fails
*/
pg_format(string $sql, ?DeparseOptions $options) : string /**
* Normalize SQL query by replacing literal values and named parameters with positional parameters.
* WHERE id = :id will be changed into WHERE id = $1
* WHERE id = 1 will be changed into WHERE id = $1.
*/
pg_normalize(string $sql) : ?string /**
* Normalize utility SQL statements (DDL like CREATE, ALTER, DROP).
* This handles DDL statements differently from pg_normalize() which is optimized for DML.
*/
pg_normalize_utility(string $sql) : ?string pg_parse(string $sql) : ParsedQuery pg_parser() : Parser /**
* Split string with multiple SQL statements into array of individual statements.
*
* @return array<string>
*/
pg_split(string $sql) : array /**
* Generate a summary of parsed queries in protobuf format.
* Useful for query monitoring and logging without full AST overhead.
*/
pg_summary(string $sql, int $options, int $truncateLimit) : string