Comments (9)
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.
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.
@andreyvit That code works fine for me. I'm running against squel 2.0.0 on node 0.11.10
from squel.
@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.
@andreyvit Yep, that's what I get when I run the code. Have you tried using it with toParam()
?
from squel.
Also, just released v3.0.1 which should improve toParam() a little bit.
from squel.
Is this still an issue?
from squel.
No idea, I've stopped using squel. @rubymaniac?
from squel.
Sorry I too stopped using squel. I have no idea if this is still an issue.
from squel.
Related Issues (20)
- Add option to add column/table name as a parameter HOT 1
- Add semantic-comparison logic for queries/expressions
- Feature request: Placeholders in the squel.case(...) expression?
- MSSQL Boolean type
- .group().having() is not a function HOT 1
- string escape is incorrect, especially when string contains \n or ', which may cause SQL injection HOT 1
- How to select into array? HOT 1
- Scalar values aliasing
- squel.select().from is undefined after minimizing HOT 6
- Numbered parameters in postgres flavour are substituted inside a string literal
- Incorrect syntax near '`'.
- SQL Server Update Fails with Trigger ? HOT 3
- Use a normal SQL string HOT 2
- Can you get the result value from an object like the result map of mybtis?
- SQL Server Select HOT 1
- Interested in Becoming an Active co-maintainer HOT 1
- How to use IGNORE in INSERT in mysql?
- Mark as deprecated HOT 1
- Grouping conditions together in expression HOT 1
- Lateral Joins
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squel.