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

can't create or update record with key containing "-" #397

Open
grimace opened this issue Nov 1, 2019 · 5 comments
Open

can't create or update record with key containing "-" #397

grimace opened this issue Nov 1, 2019 · 5 comments

Comments

@grimace
Copy link

grimace commented Nov 1, 2019

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.

@dargolith
Copy link

We also have this problem using orientjs. Possible in studio and apparently also using the java api/driver. How can we get around it?

@wolf4ood
Copy link
Member

wolf4ood commented Feb 26, 2020

Hi @dargolith

do you have an example of this failing?
Which api are you using?

Thanks

@wolf4ood
Copy link
Member

@dargolith

if you are manually writing the query you should use backtick to escape reserved character

`x-men-apocalypse`

@dargolith
Copy link

dargolith commented Mar 9, 2020

@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"

@grimace
Copy link
Author

grimace commented Mar 9, 2020

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.

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

No branches or pull requests

3 participants