sql_formatter 0.1.0 copy "sql_formatter: ^0.1.0" to clipboard
sql_formatter: ^0.1.0 copied to clipboard

A pure-Dart SQL pretty-printer supporting standard SQL, PostgreSQL, MySQL and SQLite dialects. A faithful port of the JS sql-formatter library.

Changelog #

0.1.0 #

Initial release.

  • Pure-Dart, dependency-free SQL pretty-printer — a port of the JS sql-formatter.
  • Dialects: standard SQL, PostgreSQL, MySQL/MariaDB, SQLite.
  • format(sql, {dialect, options}) with FormatOptions (indent, keywordCase, linesBetweenQueries).
  • Deterministic and idempotent output; best-effort handling of malformed SQL (no throws).
  • BETWEEN x AND y keeps its inner AND inline; later ANDs still break the line.
  • Data-type keywords are uppercased (under keywordCase.upper) inside CAST(... AS type) and ::type casts as well as CREATE TABLE column lists.
  • Linear-time output path (no per-token whole-buffer scanning), so formatting stays fast on very large inputs.
  • Unary -/+ attach to their operand (-1, LIMIT -1, a * -1) instead of being spaced like a binary operator.
  • PostgreSQL array literals and subscripts render tight and inline: ARRAY[1, 2, 3], tags[1], TEXT[].
  • DDL keywords keep their object on the same line: ALTER TABLE t …, CREATE INDEX …, CREATE VIEW …, DROP TABLE ….
  • MERGE … WHEN MATCHED … WHEN NOT MATCHED … is laid out as structured clauses (best-effort).
  • Dollar-quoted strings ($$…$$, $tag$…$tag$) are preserved verbatim in every dialect.
0
likes
160
points
77
downloads

Documentation

API reference

Publisher

verified publisher10v3n4m.cc

Weekly Downloads

A pure-Dart SQL pretty-printer supporting standard SQL, PostgreSQL, MySQL and SQLite dialects. A faithful port of the JS sql-formatter library.

Repository (GitHub)
View/report issues

Topics

#sql #formatting #database #postgresql #parser

License

MIT (license)

More

Packages that depend on sql_formatter