sql-formatter

WebJar for sql-formatter

License

License

MIT
Categories

Categories

ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

sql-formatter
Last Version

Last Version

2.3.3
Release Date

Release Date

Type

Type

jar
Description

Description

sql-formatter
WebJar for sql-formatter
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/zeroturnaround/sql-formatter

Download sql-formatter

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/sql-formatter/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>sql-formatter</artifactId>
    <version>2.3.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/sql-formatter/
implementation 'org.webjars.npm:sql-formatter:2.3.3'
// https://jarcasting.com/artifacts/org.webjars.npm/sql-formatter/
implementation ("org.webjars.npm:sql-formatter:2.3.3")
'org.webjars.npm:sql-formatter:jar:2.3.3'
<dependency org="org.webjars.npm" name="sql-formatter" rev="2.3.3">
  <artifact name="sql-formatter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='sql-formatter', version='2.3.3')
)
libraryDependencies += "org.webjars.npm" % "sql-formatter" % "2.3.3"
[org.webjars.npm/sql-formatter "2.3.3"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : lodash jar [4.16.0,5)

Project Modules

There are no modules declared in this project.

SQL Formatter NPM version Build Status Coverage Status

SQL Formatter is a JavaScript library for pretty-printing SQL queries. It started as a port of a PHP Library, but has since considerably diverged. It supports Standard SQL, Couchbase N1QL, IBM DB2 and Oracle PL/SQL dialects.

Try the demo.

Install

Get the latest version from NPM:

npm install sql-formatter

Usage

import sqlFormatter from "sql-formatter";

console.log(sqlFormatter.format("SELECT * FROM table1"));

This will output:

SELECT
  *
FROM
  table1

You can also pass in configuration options:

sqlFormatter.format("SELECT *", {
    language: "n1ql", // Defaults to "sql"
    indent: "    "   // Defaults to two spaces
});

Currently just four SQL dialects are supported:

Placeholders replacement

// Named placeholders
sqlFormatter.format("SELECT * FROM tbl WHERE foo = @foo", {
    params: {foo: "'bar'"}
}));

// Indexed placeholders
sqlFormatter.format("SELECT * FROM tbl WHERE foo = ?", {
    params: ["'bar'"]
}));

Both result in:

SELECT
  *
FROM
  tbl
WHERE
  foo = 'bar'

Usage without NPM

If you don't use a module bundler, clone the repository, run npm install and grab a file from /dist directory to use inside a <script> tag. This makes SQL Formatter available as a global variable window.sqlFormatter.

Contributing

# run linter and tests
$ npm run check

...and you're ready to poke us with a pull request.

License

MIT

org.webjars.npm

ZeroTurnaround

Our products help Java teams improve productivity & efficiency – resulting in better code, happy devs, and more reliable releases.

Versions

Version
2.3.3
2.1.0