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

Add error when a constant set is used in singleton mode #7065

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions edb/pgsql/compiler/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,15 @@ def compile_TypeCheckOp(
return result


@dispatch.compile.register(irast.ConstantSet)
def compile_ConstantSet(
expr: irast.ConstantSet, *,
ctx: context.CompilerContextLevel) -> pgast.BaseExpr:
raise errors.UnsupportedFeatureError(
"Constant sets not allowed in singleton mode",
hint="Are you passing a set into a variadic function?")


@dispatch.compile.register(irast.Array)
def compile_Array(
expr: irast.Array, *,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,19 @@ async def test_constraints_ddl_error_06(self):
};
""")

async def test_constraints_ddl_error_07(self):
async with self.assertRaisesRegexTx(
edgedb.UnsupportedFeatureError,
r'Constant sets not allowed in singleton mode'
):
await self.con.execute(r"""
CREATE TYPE ConstraintOnTest_err_07 {
CREATE PROPERTY less_than_three -> std::int64 {
CREATE CONSTRAINT std::one_of({1,2,3});
};
};
""")

async def test_constraints_tuple(self):
await self.con.execute(r"""
CREATE TYPE Transaction {
Expand Down