hiddentao/squel — pull request #47 by rubiii (2014-01-26 22:03:35+00:00)
Title: Increment queries

hey,

first of all, thanks for squel! i really enjoy using it.

i was wondering how to increment a field using squel, so i read through the documentation
and through the code, but couldn't find a way to do it.

``` sql
UPDATE foo SET count = count + 1 where id = 1
```

this is what i need. my problem is, that `#_formatValue` [always quotes the value](https://github.com/hiddentao/squel/blob/a203998973927f34c910ce93f4f7908d633326ae/src/squel.coffee#L240).
so, i can see three ways to support this.

1. add an `autoQuoteValues` option to disable quoting for a query
2. add a `quoteValue` option to the `#set` function
3. change `#set` to also accept a string for both the field and value like `#where`

the third option is what i instinctively tried before digging into the source and i think
it's the most elegant solution. but i can't think of a way to make it also work with
placeholders like `#where` does while supporting the current api.

here's an example of how it would look like:

``` javascript
squel.update().table('foo').set('count = count + 1').where('id = 1')
```

what do you think?