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

Migration creation allows invalid aggregate functions in constraints #7264

Open
jollygreenlaser opened this issue Apr 26, 2024 · 1 comment
Assignees

Comments

@jollygreenlaser
Copy link

  • EdgeDB Version: 4.7+45e4acc
  • EdgeDB CLI Version: EdgeDB CLI 5.0.0+c9dfeec
  • OS Version: Ubuntu 22, OSX 14.4.1
type User {
   name: str;
}

type HasTwoOrFewerUsers {
   users: User;
   constraint expression on (count(.users) <= 2);
}

This will work to create a migration, but then fail to apply:

InternalServerError: aggregate functions are not allowed in check constraints

If users is updated to be correctly multi then it properly fails at migration creation time:

error: cannot use aggregate functions or operators in a non-aggregating constraint

Seems this should always be caught at creation time.

@msullivan
Copy link
Member

I thought this was going to have been fixed by #7128, but it looks like we don't catch this at all, and the error comes from postgres.

The funny bit is that if users is actually a multi link, then we correctly reject it at migration create time!

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

No branches or pull requests

3 participants