Skip to content

Latest commit

 

History

History
68 lines (57 loc) · 2.65 KB

language.md

File metadata and controls

68 lines (57 loc) · 2.65 KB

language

Specifies the SQL dialect to use.

Usage

import { format } from 'sql-formatter';

const result = format('SELECT * FROM tbl', { dialect: 'sqlite' });

Options

The default "sql" dialect is meant for cases where you don't know which dialect of SQL you're about to format. It's not an auto-detection, it just supports a subset of features common enough in many SQL implementations. This might or might not work for your specific dialect. Better to always pick something more specific if possible.

Impact on bundle size

Using the language option has the downside that the used dialects are determined at runtime and therefore they all have to be bundled when e.g. building a bundle with Webpack. This can result in significant overhead when you only need to format one or two dialects.

To solve this problem, version 12 of SQL Formatter introduces a new API, that allows explicitly importing the dialects. See docs for dialect option.