Giter Club home page Giter Club logo

Comments (9)

hiddentao avatar hiddentao commented on July 26, 2024

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.

from squel.

andreyvit avatar andreyvit commented on July 26, 2024

Nope, doesn't work for me:

squel = require('squel')

class RawSql
  constructor: (@sql) ->

squel.registerValueHandler RawSql, (rawSql) ->
  return rawSql.sql

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().

from squel.

hiddentao avatar hiddentao commented on July 26, 2024

@andreyvit That code works fine for me. I'm running against squel 2.0.0 on node 0.11.10

from squel.

andreyvit avatar andreyvit commented on July 26, 2024

@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.

from squel.

hiddentao avatar hiddentao commented on July 26, 2024

@andreyvit Yep, that's what I get when I run the code. Have you tried using it with toParam()?

from squel.

hiddentao avatar hiddentao commented on July 26, 2024

Also, just released v3.0.1 which should improve toParam() a little bit.

from squel.

hiddentao avatar hiddentao commented on July 26, 2024

Is this still an issue?

from squel.

andreyvit avatar andreyvit commented on July 26, 2024

No idea, I've stopped using squel. @rubymaniac?

from squel.

rubymaniac avatar rubymaniac commented on July 26, 2024

Sorry I too stopped using squel. I have no idea if this is still an issue.

from squel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.