You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to implement a bit of data sanititation directy into the DB.
I migrate from an old DB that used 'Y' and 'N' in a string field instead of a simple boolean.
I added a simple VALUE function that is able to handle said strings and returns true on 'Y' and false on ever< other string.
Thing is that if the table is schemafull and the field is declared as boolean. The DB throws an error if I enter a string for the value even if the VALUE clause 100% guarantees to return a boolean.
Describe the solution
It would be the proper solution to disable the initial type check when a VALUE is present.
Of course the type needs to be checked again after VALUE has run, which i think is alread the case.
Alternative methods
One workaround would be to use a proxy field like this:
DEFINE FIELD foo ON test TYPE option<string> VALUE NONE;
DEFINE FIELD bar ON test TYPE bool DEFAULT foo == "Y";
This works but is not really a clean solution in my opiniion.
SurrealDB version
surreal 1.4.2 for linux on x86_64
Contact Details
No response
Is there an existing issue for this?
I have searched the existing issues
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
reinhard-sanz
changed the title
Feature: Disable initial type cheke when VALUE is present.
Feature: Disable initial type check when VALUE is present.
Apr 29, 2024
Is your feature request related to a problem?
I want to implement a bit of data sanititation directy into the DB.
I migrate from an old DB that used 'Y' and 'N' in a string field instead of a simple boolean.
I added a simple
VALUE
function that is able to handle said strings and returnstrue
on 'Y' andfalse
on ever< other string.Thing is that if the table is schemafull and the field is declared as boolean. The DB throws an error if I enter a string for the value even if the
VALUE
clause 100% guarantees to return a boolean.Describe the solution
It would be the proper solution to disable the initial type check when a
VALUE
is present.Of course the type needs to be checked again after
VALUE
has run, which i think is alread the case.Alternative methods
One workaround would be to use a proxy field like this:
This works but is not really a clean solution in my opiniion.
SurrealDB version
surreal 1.4.2 for linux on x86_64
Contact Details
No response
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: