orientjs
orientjs copied to clipboard
can't create or update record with key containing "-"
I have 'Event' records with fields like this ( x-cost-type ). I can not create/update any records and include that field in the update.
I can create/update a Vertex like this (note underscore instead of dash):
let event = {
summary: "Event Test",
pubdate: "20190319T210625Z",
contact: "Mr. Sweeny Todd",
dtstart: "2019-03-11T16:00:00Z",
dtend: "2019-03-11T18:00:00Z",
location: "Barber Shop",
'x_men_apocalypse': "paid"
}
but not like this:
let event = {
summary: "Event Test",
pubdate: "20190319T210625Z",
contact: "Mr. Sweeny Todd",
dtstart: "2019-03-11T16:00:00Z",
dtend: "2019-03-11T18:00:00Z",
location: "Barber Shop",
'x-men-apocalypse': "paid"
}
Is there a way around this? Or do I just not understand some limitation of ODB? I can create these fields in studio ( and via Java ) but not orientjs.
We also have this problem using orientjs. Possible in studio and apparently also using the java api/driver. How can we get around it?
Hi @dargolith
do you have an example of this failing? Which api are you using?
Thanks
@dargolith
if you are manually writing the query you should use backtick to escape reserved character
`x-men-apocalypse`
@wolf4ood
Sorry for replying so late.
This is what I do:
const client = await OrientDBClient.connect(dbConnectionData);
const session = await client.session(dbData);
const query = session.update(className);
query.set(properties);
If properties contain keys with "-" in their name, this throws:
Error: Error parsing query:
^
Encountered " <UPDATE> "UPDATE "" at line 1, column 1.
Was expecting one of:
<WHILE> ...
<IF> ...
<FOREACH> ...
";" ...
DB name=<myDbName>
Error Code="1"
I ran into this because I was importing events from some calendar and those events had dashes ('-') in the properties. I eventually just changed the import code to replaceAll dashes to underscores. Since it was not core to my task, I just moved on, but it's no longer an issue for me.