How to insert data that's a tuple with a reserved word as a key?

23 Views Asked by At

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`
1

There are 1 best solutions below

0
NetOperator Wibby On

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
});