Skip to content

Commit

Permalink
Add error when a constant set is used in singleton mode (#7065)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark authored and msullivan committed Mar 18, 2024
1 parent 37fb2e1 commit 4d2101f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit 4d2101f

Please sign in to comment.