Feature: Disable initial type check when `VALUE` is present.
reinhard-sanz opened this issue · comments
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 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