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

Problem Upserting records with composite (object) Ids #99

Open
erancahana opened this issue Apr 14, 2024 · 1 comment
Open

Problem Upserting records with composite (object) Ids #99

erancahana opened this issue Apr 14, 2024 · 1 comment

Comments

@erancahana
Copy link

using the driver with WS engine:

SurrealDb.Net.Exceptions.SurrealDbException : There was a problem with the database: Found 'TestRecords:{"x":"xx","z":"zz"}' for the id field, but a specific record has been specified

public class TestRecord : Record {
    public string TestA { get; set; }
    public string TestB { get; set; }
    public string TestC { get; set; }
}
...
var testRecordResult = await surrealDbClient.Upsert(new TestRecord {
        Id = Thing.From("TestRecords", new { x = "xx", z = "zz" }),
        TestA = "Something",
        TestB = null,
        TestC = "SomethingElse",
    }, CancellationToken.None
);

yields the following problem:
SurrealDb.Net.Exceptions.SurrealDbException : There was a problem with the database: Found 'TestRecords:{"x":"xx","z":"zz"}' for the id field, but a specific record has been specified

I've noticed the same issue with the HTTP engine:

PUT http://localhost:8000/key/TestRecords/{"x":"xx","z":"zz"}

with body

{
    "id": "TestRecords:{\"x\":\"xx\",\"z\":\"zz\"}",
    "TestA":"xxxx",
    "TestB":null,
    "TestC":"xxxxx"
}

does not work

but with body

{
    "id": "TestRecords:{'x':'xx','z':'zz'}",
    "TestA":"xxxx",
    "TestB":null,
    "TestC":"xxxxx"
}

does work,

so this seems like a serialization issue when escaping strings of Ids that are objects?

@Odonno
Copy link
Contributor

Odonno commented Apr 15, 2024

Hello @erancahana

This is indeed an issue with how the id is currently serialized.

FYI, this issue will be gone in the next version of the library. Until then, the best alternative to do what you want is to write a Query by hand.

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

2 participants