Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to insert data that's a tuple with a reserved word as a key #743

Open
raddevon opened this issue Sep 29, 2023 Discussed in #742 · 1 comment
Open

Document how to insert data that's a tuple with a reserved word as a key #743

raddevon opened this issue Sep 29, 2023 Discussed in #742 · 1 comment

Comments

@raddevon
Copy link
Contributor

Discussed in #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
});
@msullivan
Copy link
Member

The query builder probably ought to automatically quote reserved names by itself, though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants