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

Feature: Disable initial type check when VALUE is present. #3963

Open
2 tasks done
reinhard-sanz opened this issue Apr 29, 2024 · 0 comments
Open
2 tasks done

Feature: Disable initial type check when VALUE is present. #3963

reinhard-sanz opened this issue Apr 29, 2024 · 0 comments
Labels
feature New feature or request triage This issue is new

Comments

@reinhard-sanz
Copy link

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.

image

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
@reinhard-sanz reinhard-sanz added feature New feature or request triage This issue is new labels Apr 29, 2024
@reinhard-sanz 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request triage This issue is new
Projects
None yet
Development

No branches or pull requests

1 participant