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

casts from json to scalar subtypes don't check constraints #5616

Closed
msullivan opened this issue Jun 7, 2023 · 0 comments · Fixed by #5624
Closed

casts from json to scalar subtypes don't check constraints #5616

msullivan opened this issue Jun 7, 2023 · 0 comments · Fixed by #5624
Assignees

Comments

@msullivan
Copy link
Member

edgedb> create scalar type x extending str { create constraint expression on (__subject__ not like 'a%') };
OK: CREATE SCALAR TYPE
edgedb> select <x>to_json('"a"');
["a"]
edgedb> select <x><str>to_json('"a"');
edgedb error: ConstraintViolationError: invalid x
  Detail: invalid scalar type 'default::x'

select <x>to_json('"a"') ought to raise an error also.

(I don't think this is specific to json, of course.)
I think the issue is that we are only ever casting to text. We never emit a cast to the real target type.

msullivan pushed a commit that referenced this issue Jun 9, 2023
We've had a codepath to fix this bug for enum already, but now I extended it to anything that:

 * is a scalar,
 * it not the top-most concrete base of itself,

Closes #5616
msullivan pushed a commit that referenced this issue Jun 9, 2023
We've had a codepath to fix this bug for enum already, but now I extended it to anything that:

 * is a scalar,
 * it not the top-most concrete base of itself,

Closes #5616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants