• Blog
  • Archives
  • Code
  • Talks
  • About

Squel 1.0.6 with automatic name quoting

Note: This post is over 6 months old and may now be out of date. Some of the links not work anymore.

(1 minute read)

Squel version 1.0.6 is now out. You can now tell Squel to automatically quote table and field names. In addition the query builder options code was refactored and simplified.

How to use

Let's say you build a query:

  .field("name", "Student name");

By default this will give you:

SELECT name AS "Student name" FROM students

Now you can pass in the following options:

  autoQuoteTableNames: true,
  autoQuoteFieldNames: true,
  nameQuoteCharacter: '|'
  .field("name", "Student name");

This will give:

SELECT |name| AS "Student name" FROM |students|

Note: if nameQuoteCharacter is ommitted then ` is assumed to be the quote character.

Download it

Install squel using npm:

$ npm install squel

Homepage: squeljs.org

Github: github.com/hiddentao/squel