Open tomsseisums opened 2 years ago
WARNING: Up to this date I've never seen surrealdb code, my observations may be wrong. Furthermore this "note" is in a continuous progress - expect changes
I would love to see the separate bug issues, than this large one. If @tobiemh allows me to do that I will split this into smaller parts and add references in this comment
From the given issue one may separate following issues (these three links below are not working, but they refer to the sections of this comment)
Other reference type allowed
Messed up ID's
Assertions fail even for correct values
I don't see type check in any form EXCEPT the following one. There is type casting on the level of parsing SurrealQL, but I cannot see anywhere (as of my fast research) validation of the data.
Maybe SurrealDB should add an option to force certain types without conversion. Ex. create without type creation
CREATE User:MyUser CONTENT { "name": 123 } STRICT
Clauses with such a flag will skip value conversion on the level of the Value
and automatically check for type on the within document operations. This functionality can be placed within store method, or just before any call of it. SurrealDB can also use check method for this
See below
Both of the issues seem to be caused by the fact that assertions are evaluated on the level of SurrealQL parsing. The values are assigned to them at the later process
See an answer to the related issue
In order to fix this/find a more in-depth cause of these problems I would like to know:
Describe the bug
I was looking into a flow where one could predefine edge table by specifying fields on them but in turn I found out real wonky behavior.
With complex ID's now enabled for edge tables with
beta.8
, we can have this powerful thing (ran on a completely empty DB):That spits out a real nice:
But then, trying to pre-define an edge table, leads to real messed up results (see next section).
Steps to reproduce
When using this definition:
1️⃣ Messed up ID
Running this:
Produces:
2️⃣ Other reference type allowed
And running this, does not take into account the type hint on
in
&out
fields:Producing:
3️⃣✅ Assertions fail even for correct values
But this is even weirder case, trying to enforce types with assertions:
Even the correct
RELATE
statement now fails:Producing:
Expected behaviour
1️⃣ Messed up ID's
I'd expect for a valid complex
id
to be generated akin to this statement:But maybe a different expression needs to be used for
VALUE
there?2️⃣ Other reference type allowed
For standard tables, for a field with
TYPE record(x)
, when creating a record that tries to reference some other type thanx
, the field is omitted.But because graphs are somewhat a built in thing with different semantics as well as behavior, where omitting a field in case it doesn't match the given record type doesn't make sense, I'd want to see an error raised by Surreal.
3️⃣✅ Assertions fail even for correct values
It seems that the ordering of operations is messed up or something, but I'd expect that I could run assertions on
in
,out
fields and the$value
would be available for assertions.SurrealDB version
surreal 1.0.0-beta.8 for macos on aarch64
Contact Details
@tomsseisums
Is there an existing issue for this?
Code of Conduct