-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
The library works otherwise, but this makes invalid SQL:
import format from 'sqlutils/pg/format.js'
const records = [
{
run: '1692826907-allwords',
platform: 'APPLE',
locale: 'en-US',
term: 'electricity',
rank: 10,
total: 10,
score: 4,
result: 'electricity bill calculator $',
ip: '127.0.0.1',
pass: 1
}
]
// copy to show that records is being modified in-place
const original = JSON.parse(JSON.stringify(records))
const query = format('INSERT INTO results ?', records)
console.log(JSON.stringify({ query, original, records }, null, 2))Looks like it doesn't like the $, which is valid for duckdb (which uses postgres sql syntax)
Additionally, it appears to be modifying my input, in-place, which is very bad.
{
"query": "INSERT INTO results (run,platform,locale,term,rank,total,score,result,ip,pass) VALUES ('1692826907-allwords','APPLE','en-US','electricity',10,10,4,'electricity bill calculator ,'127.0.0.1',1)",
"original": [
{
"run": "1692826907-allwords",
"platform": "APPLE",
"locale": "en-US",
"term": "electricity",
"rank": 10,
"total": 10,
"score": 4,
"result": "electricity bill calculator $",
"ip": "127.0.0.1",
"pass": 1
}
],
"records": [
{
"run": "'1692826907-allwords'",
"platform": "'APPLE'",
"locale": "'en-US'",
"term": "'electricity'",
"rank": "10",
"total": "10",
"score": "4",
"result": "'electricity bill calculator $'",
"ip": "'127.0.0.1'",
"pass": "1"
}
]
}Metadata
Metadata
Assignees
Labels
No labels