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

String incorrectly interpreted as record in Schemafull table #96

Open
J05HM0N5TER opened this issue Apr 5, 2024 · 2 comments
Open

String incorrectly interpreted as record in Schemafull table #96

J05HM0N5TER opened this issue Apr 5, 2024 · 2 comments

Comments

@J05HM0N5TER
Copy link

J05HM0N5TER commented Apr 5, 2024

I have a scemafull with a field defined as string and if I set it to a string which is in the form of a record (e.g. test:string) then it throws an exception. There is a workaround in surrealql, but I don't know how to do that in this SDK.

Minimal replication example:

using SurrealDb.Net;
using SurrealDb.Net.Models.Auth;

public class Test {
    public required string Name { get; set; }
}

var db = new SurrealDbClient("ws://127.0.0.1:8000/rpc");
await db.SignIn(new RootAuth { Username = "root", Password = "root" });
await db.Use("test", "test");

const string tableName = "test";

await db.RawQuery(@$"DEFINE TABLE {tableName} SCHEMAFULL;
DEFINE FIELD name ON TABLE {tableName} TYPE string;");

await db.Create<Test>(tableName, new Test(){Name = "Test normal data"});
await db.Create<Test>(tableName, new Test(){Name = "Test normal data2"});
await db.Create<Test>(tableName, new Test(){Name = "Test normal data3"});
await db.Create<Test>(tableName, new Test(){Name = "example:string"});

Where it throws Error: SurrealDb.Net.Exceptions.SurrealDbException: There was a problem with the database: Found example:string for field `name`, with record `test:djqxpvplqi7eorq6pp9t`, but expected a string

As a workaround, I can set the type to be any, but that is no longer representative of the data I am putting in it.

@Odonno
Copy link
Contributor

Odonno commented Apr 5, 2024

Hello Josh,

Unfortunately, the only solution for this to work is to write the Query by hand. This bug will be fixed in the future.

@J05HM0N5TER
Copy link
Author

Hello Josh,

Unfortunately, the only solution for this to work is to write the Query by hand. This bug will be fixed in the future.

Thanks for the quick reply.

I am just planning on using any for now, since it works with my existing code and I think I can change it later if I need to.

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