Skip to content

feat(ffi): expose sqlglot_generate_pretty with dialect-aware formatting#24

Open
gauravs wants to merge 1 commit into
protegrity:masterfrom
AccountAim:feat/pretty-generate-ffi
Open

feat(ffi): expose sqlglot_generate_pretty with dialect-aware formatting#24
gauravs wants to merge 1 commit into
protegrity:masterfrom
AccountAim:feat/pretty-generate-ffi

Conversation

@gauravs

@gauravs gauravs commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Adds pretty-printing to the FFI and fixes generate_pretty to actually respect the target dialect.

Previously generate_pretty(ast, dialect) ignored its dialect argument, so formatted output always used source/ANSI quoting instead of the target's.

Changes

  • Fix generate_pretty to honor the target dialect
  • Add Generator::generate_pretty method; deprecate Generator::pretty
  • New FFI export sqlglot_generate_pretty; update C/C++ examples and docs
  • Bump 0.10.17

Before / after

Parsing MySQL and pretty-printing as T-SQL:

let ast = parse("SELECT `select` FROM `events`", Dialect::Mysql).unwrap();
let out = generate_pretty(&ast, Dialect::Tsql);

// Before — dialect ignored, MySQL backticks leak through:
SELECT
  `select`
FROM
  `events`

// After — normalized to T-SQL quoting:
SELECT
  [select]
FROM
  [events]

- fix generate_pretty to honor the target dialect (previously ignored)
- add Generator::generate_pretty method; deprecate Generator::pretty
- add sqlglot_generate_pretty FFI export; update C/C++ examples and docs
- bump 0.10.17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant