This tool is a simple formatter for SQL.
The currently supported SQL syntax is minimum that maintainers use on a daily basis.
- [ ] Support various syntax
- [ ] Support RDBMS-specific dialects
# print formatted SQL in <file.sql> to stdout
$ ocaml-sql-format file.sql
# You can redirect to other file
$ ocaml-sql-format file.sql > other.sql
# Can pass multiple files as arguments
$ ocaml-sql-format file1.sql file2.sql
# In-place update
$ ocaml-sql-format -w file.sql
$ ocaml-sql-format --write file.sql
# Specify configuration
$ ocaml-sql-format -c <config file> file.sql
Users can change some behaviors by configuration file. Format of configuration file is toml. Configuration file content is below.
[settings]
# format SQL keywords to UPPERCASE or lowercase
# Default value is `upper`
keyword = "lower" # lowercase
keyword = "upper" # UPPERCASE
# Size of indentation that is used to some statement, such as select, update, or some expressions.
# Default value is 4
indent_size = 2
# Maximum line length to detect wrap expression.
# Default value is 100
max_line_length = 80
This repository uses Task to manage some development tasks. But if you do not install Task, you can use dune directly.
- dune
- opam
- Task (optional)
# build executable
$ task build
# bulid tools for development
$ task build-tool
# run teest
$ task test
# promote result into expectation tests
$ task promote
Keyword generation for sedlex.
task keyword KEYWORD=<keyword>
Syntax generation. This command generates OCaml sources for Cst/Printer/Parser
$ task new-ast -- "syntax name"
MIT