edgedb-js
edgedb-js copied to clipboard
Document how to insert data that's a tuple with a reserved word as a key
Discussed in https://github.com/edgedb/edgedb-js/discussions/742
Originally posted by NetOpWibby September 29, 2023
Problem
"refresh" is an reserved word in EdgeDB so the below will not work.
query.data = {
expire: query.expire,
minimum: query.minimum,
mname: query.mname,
refresh: query.refresh,
retry: query.retry,
rname: query.rname,
serial: query.serial
};
EdgeQLSyntaxError: Unexpected keyword 'refresh'
|
6 | data := ( expire := <std::float64>604800,minimum := <std::float64>86400,mname := "ns1.app.beachfront",refresh := <std::float64>3600,retry := <std::float64>1800,rname := "administrator.app.beachfront",serial := <std::float64>2023092801 )
| ^^^^^^^
Hint: Use a different identifier or quote the name with backticks: `refresh`
Solution
Entire object should be wrapped in e.tuple and the reserved keyboard should be quoted AND have backticks.
query.data = e.tuple({
expire: query.expire,
minimum: query.minimum,
mname: query.mname,
"`refresh`": query.refresh,
retry: query.retry,
rname: query.rname,
serial: query.serial
});
The query builder probably ought to automatically quote reserved names by itself, though