You can clone with
HTTPS or Subversion.
I want to construct the following query:
UPDATE users SET password = crypt('my super awesome password', gen_salt('md5'))
and it is not obvious how I have to go in order to not have the crypt function to get interpreted as a string value. I do not want to use the usingValuePlaceholders option because it is deprecated. Is there any other way?
Yep, you can use a custom value type. Just represent the crypt('my super awesome password', gen_salt('md5')) part as a CryptFunction class or something and then register that value type with squel along with a handler. Then everytime squel encounters an instance of that class it will pass it off to your custom handler to get the string representation.
crypt('my super awesome password', gen_salt('md5'))
Nope, doesn't work for me:
squel = require('squel')
constructor: (@sql) ->
squel.registerValueHandler RawSql, (rawSql) ->
squel.sql = (sql) -> new RawSql(sql)
console.log('%s', squel.insert().into('widgets').set('foo', 42).set('created_at', squel.sql('NOW()')))
# INSERT INTO widgets (foo, created_at) VALUES (42, 'NOW()')
What I need is an unquoted raw value. I think this absolutely must be a part of the library; pretty much every app requires access to NOW().
@andreyvit That code works fine for me. I'm running against squel 2.0.0 on node 0.11.10
@hiddentao By ‘works fine’, do you mean it produces this?
INSERT INTO widgets (foo, created_at) VALUES (42, NOW())
Anyways, obviously toString isn't the primary use case, and I cannot see how it can possibly work with toParam, given that you give all the output strings to the native driver as values.
@andreyvit Yep, that's what I get when I run the code. Have you tried using it with toParam()?
Also, just released v3.0.1 which should improve toParam() a little bit.
Is this still an issue?
No idea, I've stopped using squel. @rubymaniac?
Sorry I too stopped using squel. I have no idea if this is still an issue.