Open lveillard opened 2 weeks ago
This isn't really a bug, but is intended behavior. Functions require a certain type and we don't do anything special for when a value doesn't exist. You will have to check if a value exists if it can be none before handing it to a function that requires a value.
Yes! The bug was a bit different but im not able define it properly. On the other hand, while the type errors make sense on other places (mainly mutations) the where clause could get a dx boost if the errors where just treated as a false and throw the error silently in the logs as a warning.
But i understand it might be non cannonical behavior
This is the closest I've been to the bug
DEFINE TABLE UserTag SCHEMAFULL PERMISSIONS FULL;
DEFINE FIELD name ON TABLE UserTag TYPE option<string>;
DEFINE FIELD color ON TABLE UserTag VALUE <future> {RETURN SELECT VALUE group.color FROM ONLY $this};
DEFINE FIELD group ON TABLE UserTag TYPE option<record<UserTagGroup>>;
INSERT INTO ⟨UserTag⟩ [
{ id: "tag-1", group: UserTagGroup:`utg-1`},
{ id: "tag-2", group: UserTagGroup:`utg-1` },
{ id: "tag-3", group: UserTagGroup:`utg-2` },
{ id: "tag-4" }
];
INSERT INTO ⟨Color⟩ [
{ id: "yellow", freeForAll: 7 },
{ id: "blue", freeForAll: "hey" },
{ id: "red", freeForAll: "yay" }
];
INSERT INTO ⟨UserTagGroup⟩ [
{ id: "utg-1", color: Color:yellow },
{ id: "utg-2", color: Color:blue }
];
SELECT color FROM UserTag;
SELECT * FROM UserTag WHERE color; // this should filter the one with NONE
SELECT * FROM UserTag WHERE color[WHERE id == Color:yellow ] //this should show only those connected to utg-1
I would expect tge last two queries to work but they don't. They look like two different issues tho.
Describe the bug
Using filters on optional props might throw errors.
Steps to reproduce
Expected behaviour
Ideally, this should work
Alternatives
SurrealDB version
2.0.0.beta3
Contact Details
No response
Is there an existing issue for this?
Code of Conduct