SQLFormatter (sql_formatter v1.0.1)

View Source

Summary

Functions

Formats a SQL string.

Types

opts()

@type opts() :: [
  indent: non_neg_integer(),
  uppercase: boolean(),
  lines_between_queries: non_neg_integer()
]

Functions

format(sql, opts \\ [])

@spec format(String.t(), opts()) :: String.t()

Formats a SQL string.

Options

  • :indent: The number of spaces to indent the formatted SQL. Defaults to 2.
  • :uppercase: Whether to use uppercase for keywords. Defaults to false.
  • :lines_between_queries: The number of lines to insert between queries. Defaults to 1.

Examples

SQLFormatter.format("SELECT * FROM users")
#=>
"""
SELECT
  *
FROM
  users
"""
SQLFormatter.format("SELECT * FROM users", indent: 4)
#=>
"""
SELECT
    *
FROM
    users
"""