Comments (6)
There are two approaches:
- Set
{usingValuePlaceholders: true}
and then manually add quotes arounddata.comment
. - Customize the
Insert
query builder with a custom version ofSetFieldBlock
which will let you do what you want.
If this is a problem for more people perhaps I can modify the built-in SetFieldBlock
to allow for options overrides.
from squel.
This works but might be a bit "hacky":
sql = squel.insert({ usingValuePlaceholders: true })
.into('flags')
.set('time', time)
.set('type', data.type)
.set('comment', '\'' + data.comment + '\'')
.set('geom', 'PointFromText(\'POINT(' + data.latlng.lng + ' ' + data.latlng.lat + ')\', 4326)');
from squel.
An optional options object per field block would be sweet! Thanks again for the great lib ;)
from squel.
I think that customizing the query builder is the way to go for you if you want to do many such queries in a less hacky way. Full customization examples are available in the docs.
from squel.
Yep, each field block does already get its own copy of the options
object.
from squel.
Sorry, meant to say each block does get its own copy of the options
object. I see what you were saying now about each set()
having its own options
object.
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.