diff --git a/edb/testbase/server.py b/edb/testbase/server.py index 3b1feccbd70..ea6d3cd4604 100644 --- a/edb/testbase/server.py +++ b/edb/testbase/server.py @@ -978,7 +978,7 @@ async def wf(self, *args, **kwargs): class ConnectedTestCase(ClusterTestCase): BASE_TEST_CLASS = True - NO_FACTOR = False + NO_FACTOR = True WARN_FACTOR = False con: tconn.Connection diff --git a/tests/test_edgeql_calls.py b/tests/test_edgeql_calls.py index 5a9d7a52189..4dbcfb2d4ed 100644 --- a/tests/test_edgeql_calls.py +++ b/tests/test_edgeql_calls.py @@ -26,8 +26,6 @@ class TestEdgeQLFuncCalls(tb.QueryTestCase): - NO_FACTOR = True - async def test_edgeql_calls_01(self): await self.con.execute(''' CREATE FUNCTION call1( diff --git a/tests/test_edgeql_casts.py b/tests/test_edgeql_casts.py index 0734d964992..c91a38c2ee8 100644 --- a/tests/test_edgeql_casts.py +++ b/tests/test_edgeql_casts.py @@ -49,6 +49,7 @@ class TestEdgeQLCasts(tb.QueryTestCase): If x can be losslessly cast into Y, then casting it back is also lossless: x = x ''' + # FIXME: a special schema should be used here since we need to # cover all known scalars and even some arrays and tuples. SCHEMA = os.path.join(os.path.dirname(__file__), 'schemas', @@ -542,7 +543,7 @@ async def test_edgeql_casts_str_02(self): # values. await self.assert_query_result( r''' - WITH x := {'true', 'false'} + FOR x in {'true', 'false'} SELECT x = x; ''', [True, True], @@ -550,7 +551,7 @@ async def test_edgeql_casts_str_02(self): await self.assert_query_result( r''' - WITH x := {'True', 'False', 'TRUE', 'FALSE', ' TrUe '} + FOR x in {'True', 'False', 'TRUE', 'FALSE', ' TrUe '} SELECT x = x; ''', [False, False, False, False, False], @@ -558,7 +559,7 @@ async def test_edgeql_casts_str_02(self): await self.assert_query_result( r''' - WITH x := {'True', 'False', 'TRUE', 'FALSE', 'TrUe'} + FOR x in {'True', 'False', 'TRUE', 'FALSE', 'TrUe'} SELECT x = str_lower(x); ''', [True, True, True, True, True], @@ -580,7 +581,7 @@ async def test_edgeql_casts_str_03(self): # str to json is always lossless await self.assert_query_result( r''' - WITH x := {'any', 'arbitrary', '♠gibberish♠'} + FOR x in {'any', 'arbitrary', '♠gibberish♠'} SELECT x = x; ''', [True, True, True], @@ -590,7 +591,7 @@ async def test_edgeql_casts_str_04(self): # canonical uuid representation as a string is using lowercase await self.assert_query_result( r''' - WITH x := 'd4288330-eea3-11e8-bc5f-7faf132b1d84' + FOR x in 'd4288330-eea3-11e8-bc5f-7faf132b1d84' SELECT x = x; ''', [True], @@ -599,7 +600,7 @@ async def test_edgeql_casts_str_04(self): await self.assert_query_result( # non-canonical r''' - WITH x := { + FOR x in { 'D4288330-EEA3-11E8-BC5F-7FAF132B1D84', 'D4288330-Eea3-11E8-Bc5F-7Faf132B1D84', 'D4288330-eea3-11e8-bc5f-7faf132b1d84', @@ -611,7 +612,7 @@ async def test_edgeql_casts_str_04(self): await self.assert_query_result( r''' - WITH x := { + FOR x in { 'D4288330-EEA3-11E8-BC5F-7FAF132B1D84', 'D4288330-Eea3-11E8-Bc5F-7Faf132B1D84', 'D4288330-eea3-11e8-bc5f-7faf132b1d84', @@ -627,7 +628,7 @@ async def test_edgeql_casts_str_05(self): # in UTC time zone. await self.assert_query_result( r''' - WITH x := '2018-05-07T20:01:22.306916+00:00' + FOR x in '2018-05-07T20:01:22.306916+00:00' SELECT x = x; ''', [True], @@ -636,7 +637,7 @@ async def test_edgeql_casts_str_05(self): await self.assert_query_result( # validating that these are all in fact the same datetime r''' - WITH x := { + FOR x in { '2018-05-07T15:01:22.306916-05:00', '2018-05-07T15:01:22.306916-05', '2018-05-07T20:01:22.306916Z', @@ -690,7 +691,7 @@ async def test_edgeql_casts_str_06(self): # in UTC time zone. await self.assert_query_result( r''' - WITH x := '2018-05-07T20:01:22.306916' + FOR x in '2018-05-07T20:01:22.306916' SELECT x = x; ''', [True], @@ -699,7 +700,7 @@ async def test_edgeql_casts_str_06(self): await self.assert_query_result( # validating that these are all in fact the same datetime r''' - WITH x := { + FOR x in { # the '-' and ':' separators may be omitted '20180507T200122.306916', # acceptable RFC 3339 @@ -755,7 +756,7 @@ async def test_edgeql_casts_str_07(self): # 8601. await self.assert_query_result( r''' - WITH x := '2018-05-07' + FOR x in '2018-05-07' SELECT x = x; ''', [True], @@ -764,7 +765,7 @@ async def test_edgeql_casts_str_07(self): await self.assert_query_result( # validating that these are all in fact the same date r''' - WITH x := { + FOR x in { # the '-' separators may be omitted '20180507', } @@ -802,7 +803,7 @@ async def test_edgeql_casts_str_08(self): # 8601. await self.assert_query_result( r''' - WITH x := '20:01:22.306916' + FOR x in '20:01:22.306916' SELECT x = x; ''', [True], @@ -810,7 +811,7 @@ async def test_edgeql_casts_str_08(self): await self.assert_query_result( r''' - WITH x := { + FOR x in { '20:01', '20:01:00', # the ':' separators may be omitted @@ -838,7 +839,7 @@ async def test_edgeql_casts_str_09(self): # Canonical duration await self.assert_query_result( r''' - WITH x := 'PT20H1M22.306916S' + FOR x in 'PT20H1M22.306916S' SELECT x = x; ''', [True], @@ -847,7 +848,7 @@ async def test_edgeql_casts_str_09(self): await self.assert_query_result( # non-canonical r''' - WITH x := { + FOR x in { '20:01:22.306916', '20h 1m 22.306916s', '20 hours 1 minute 22.306916 seconds', @@ -862,7 +863,7 @@ async def test_edgeql_casts_str_09(self): await self.assert_query_result( # validating that these are all in fact the same duration r''' - WITH x := { + FOR x in { '20:01:22.306916', '20h 1m 22.306916s', '20 hours 1 minute 22.306916 seconds', @@ -879,7 +880,7 @@ async def test_edgeql_casts_str_10(self): # there's no whitespace, which is trimmed await self.assert_query_result( r''' - WITH x := {'-20', '0', '7', '12345'} + FOR x in {'-20', '0', '7', '12345'} SELECT x = x; ''', [True, True, True, True], @@ -887,7 +888,7 @@ async def test_edgeql_casts_str_10(self): await self.assert_query_result( r''' - WITH x := {'-20', '0', '7', '12345'} + FOR x in {'-20', '0', '7', '12345'} SELECT x = x; ''', [True, True, True, True], @@ -895,7 +896,7 @@ async def test_edgeql_casts_str_10(self): await self.assert_query_result( r''' - WITH x := {'-20', '0', '7', '12345'} + FOR x in {'-20', '0', '7', '12345'} SELECT x = x; ''', [True, True, True, True], @@ -904,7 +905,7 @@ async def test_edgeql_casts_str_10(self): await self.assert_query_result( # with whitespace r''' - WITH x := { + FOR x in { ' 42', '42 ', ' 42 ', @@ -917,7 +918,7 @@ async def test_edgeql_casts_str_10(self): await self.assert_query_result( # validating that these are all in fact the same value r''' - WITH x := { + FOR x in { ' 42', '42 ', ' 42 ', @@ -934,7 +935,7 @@ async def test_edgeql_casts_str_11(self): # lossy. await self.assert_query_result( r''' - WITH x := {'-20', '0', '7.2'} + FOR x in {'-20', '0', '7.2'} SELECT x = x; ''', [True, True, True], @@ -942,7 +943,7 @@ async def test_edgeql_casts_str_11(self): await self.assert_query_result( r''' - WITH x := {'-20', '0', '7.2'} + FOR x in {'-20', '0', '7.2'} SELECT x = x; ''', [True, True, True], @@ -951,7 +952,7 @@ async def test_edgeql_casts_str_11(self): await self.assert_query_result( # non-canonical r''' - WITH x := { + FOR x in { '0.0000000001234', '1234E-13', '0.1234e-9', @@ -963,7 +964,7 @@ async def test_edgeql_casts_str_11(self): await self.assert_query_result( r''' - WITH x := { + FOR x in { '0.0000000001234', '1234E-13', '0.1234e-9', @@ -976,7 +977,7 @@ async def test_edgeql_casts_str_11(self): await self.assert_query_result( # validating that these are all in fact the same value r''' - WITH x := { + FOR x in { '0.0000000001234', '1234E-13', '0.1234e-9', @@ -991,7 +992,7 @@ async def test_edgeql_casts_str_12(self): # use of scientific notation. await self.assert_query_result( r''' - WITH x := { + FOR x in { '-20', '0', '7.2', '0.0000000001234', '1234.00000001234' } SELECT x = x; @@ -1002,7 +1003,7 @@ async def test_edgeql_casts_str_12(self): await self.assert_query_result( # non-canonical r''' - WITH x := { + FOR x in { '1234E-13', '0.1234e-9', } @@ -1014,7 +1015,7 @@ async def test_edgeql_casts_str_12(self): await self.assert_query_result( # validating that these are all in fact the same date r''' - WITH x := { + FOR x in { '1234E-13', '0.1234e-9', } @@ -1156,7 +1157,7 @@ async def test_edgeql_casts_numeric_01(self): # technically we're already casting a literal int64 # to int16 first f''' - WITH x := {{-32768, -32767, -100, + FOR x in {{-32768, -32767, -100, 0, 13, 32766, 32767}} SELECT <{numtype}>x = x; ''', @@ -1167,7 +1168,7 @@ async def test_edgeql_casts_numeric_01(self): # technically we're already casting a literal int64 # to int32 first f''' - WITH x := {{-2147483648, -2147483647, -65536, -100, + FOR x in {{-2147483648, -2147483647, -65536, -100, 0, 13, 32768, 2147483646, 2147483647}} SELECT <{numtype}>x = x; ''', @@ -1176,7 +1177,7 @@ async def test_edgeql_casts_numeric_01(self): await self.assert_query_result( f''' - WITH x := {{ + FOR x in {{ -9223372036854775808, -9223372036854775807, -4294967296, @@ -1203,7 +1204,7 @@ async def test_edgeql_casts_numeric_02(self): # technically we're already casting a literal int64 or # float64 to float32 first r''' - WITH x := {-3.31234e+38, -1.234e+12, -1.234e-12, + FOR x in {-3.31234e+38, -1.234e+12, -1.234e-12, -100, 0, 13, 1.234e-12, 1.234e+12, 3.4e+38} SELECT x = x; ''', @@ -1212,7 +1213,7 @@ async def test_edgeql_casts_numeric_02(self): await self.assert_query_result( r''' - WITH x := {-1.61234e+308, -1.234e+42, -1.234e-42, + FOR x in {-1.61234e+308, -1.234e+42, -1.234e-42, -100, 0, 13, 1.234e-42, 1.234e+42, 1.7e+308} SELECT x = x; @@ -1230,7 +1231,7 @@ async def test_edgeql_casts_numeric_03(self): await self.assert_query_result( # ints <= 2^24 can be represented exactly in a float32 r''' - WITH x := {16777216, 16777215, 16777214, + FOR x in {16777216, 16777215, 16777214, 1677721, 167772, 16777} SELECT x = x; ''', @@ -1240,7 +1241,7 @@ async def test_edgeql_casts_numeric_03(self): await self.assert_query_result( # max int32 -100, -1000 r''' - WITH x := {2147483548, 2147482648} + FOR x in {2147483548, 2147482648} SELECT x = x; ''', [False, False], @@ -1248,7 +1249,7 @@ async def test_edgeql_casts_numeric_03(self): await self.assert_query_result( r''' - WITH x := {2147483548, 2147482648} + FOR x in {2147483548, 2147482648} SELECT x; ''', [2147483520, 2147482624], @@ -1258,7 +1259,7 @@ async def test_edgeql_casts_numeric_04(self): await self.assert_query_result( # ints <= 2^24 can be represented exactly in a float32 r''' - WITH x := {16777216, 16777215, 16777214, + FOR x in {16777216, 16777215, 16777214, 1677721, 167772, 16777} SELECT x = x; ''', @@ -1268,7 +1269,7 @@ async def test_edgeql_casts_numeric_04(self): await self.assert_query_result( # max int32 -1, -2, -3, -10, -100, -1000 r''' - WITH x := {2147483647, 2147483646, 2147483645, + FOR x in {2147483647, 2147483646, 2147483645, 2147483638, 2147483548, 2147482648} SELECT x = x; ''', @@ -1282,7 +1283,7 @@ async def test_edgeql_casts_numeric_05(self): await self.assert_query_result( r''' # 2^31 -1, -2, -3, -10 - WITH x := {2147483647, 2147483646, 2147483645, + FOR x in {2147483647, 2147483646, 2147483645, 2147483638} # 2147483647 is the max int32 SELECT x <= 2147483647; @@ -2218,7 +2219,7 @@ async def test_edgeql_casts_json_07(self): # in UTC time zone. await self.assert_query_result( r''' - WITH x := '2018-05-07T20:01:22.306916+00:00' + FOR x in '2018-05-07T20:01:22.306916+00:00' SELECT x = x; ''', [True], @@ -2227,7 +2228,7 @@ async def test_edgeql_casts_json_07(self): await self.assert_query_result( # validating that these are all in fact the same datetime r''' - WITH x := { + FOR x in { '2018-05-07T15:01:22.306916-05:00', '2018-05-07T15:01:22.306916-05', '2018-05-07T20:01:22.306916Z', @@ -2288,7 +2289,7 @@ async def test_edgeql_casts_json_08(self): # in UTC time zone. await self.assert_query_result( r''' - WITH x := '2018-05-07T20:01:22.306916' + FOR x in '2018-05-07T20:01:22.306916' SELECT x = x; ''', [True], @@ -2297,7 +2298,7 @@ async def test_edgeql_casts_json_08(self): await self.assert_query_result( # validating that these are all in fact the same datetime r''' - WITH x := { + FOR x in { # the '-' and ':' separators may be omitted '20180507T200122.306916', # acceptable RFC 3339 @@ -2358,7 +2359,7 @@ async def test_edgeql_casts_json_09(self): # 8601. await self.assert_query_result( r''' - WITH x := '2018-05-07' + FOR x in '2018-05-07' SELECT x = x; ''', [True], @@ -2368,7 +2369,7 @@ async def test_edgeql_casts_json_09(self): # validating that these are all in fact the same date r''' # the '-' separators may be omitted - WITH x := '20180507' + FOR x in '20180507' SELECT x = '2018-05-07'; ''', @@ -2409,7 +2410,7 @@ async def test_edgeql_casts_json_10(self): # 8601. await self.assert_query_result( r''' - WITH x := '20:01:22.306916' + FOR x in '20:01:22.306916' SELECT x = x; ''', [True], @@ -2417,7 +2418,7 @@ async def test_edgeql_casts_json_10(self): await self.assert_query_result( r''' - WITH x := { + FOR x in { '20:01', '20:01:00', # the ':' separators may be omitted diff --git a/tests/test_edgeql_coalesce.py b/tests/test_edgeql_coalesce.py index 3534539b7b7..626f4f06ba2 100644 --- a/tests/test_edgeql_coalesce.py +++ b/tests/test_edgeql_coalesce.py @@ -50,6 +50,7 @@ async def test_edgeql_coalesce_scalar_01(self): sort=lambda x: x['time_estimate'] ) + @tb.needs_factoring async def test_edgeql_coalesce_scalar_02(self): await self.assert_query_result( r''' @@ -145,6 +146,7 @@ async def test_edgeql_coalesce_scalar_07(self): sort=lambda x: x['number'] ) + @tb.needs_factoring async def test_edgeql_coalesce_scalar_08(self): await self.assert_query_result( r''' @@ -225,6 +227,7 @@ async def test_edgeql_coalesce_scalar_11(self): ] ) + @tb.needs_factoring async def test_edgeql_coalesce_scalar_12(self): await self.assert_query_result( r''' @@ -305,6 +308,7 @@ async def test_edgeql_coalesce_set_02(self): sort=lambda x: x['te'] ) + @tb.needs_factoring async def test_edgeql_coalesce_set_03(self): await self.assert_query_result( r''' @@ -391,6 +395,7 @@ async def test_edgeql_coalesce_set_07(self): sort=lambda x: x['number'] ) + @tb.needs_factoring async def test_edgeql_coalesce_set_08(self): await self.assert_query_result( r''' @@ -480,6 +485,7 @@ async def test_edgeql_coalesce_dependent_01(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_02(self): await self.assert_query_result( r''' @@ -499,6 +505,7 @@ async def test_edgeql_coalesce_dependent_02(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_03(self): await self.assert_query_result( r''' @@ -649,6 +656,7 @@ async def test_edgeql_coalesce_dependent_11(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_12(self): await self.assert_query_result( r''' @@ -668,6 +676,7 @@ async def test_edgeql_coalesce_dependent_12(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_13(self): await self.assert_query_result( r''' @@ -702,6 +711,7 @@ async def test_edgeql_coalesce_dependent_14(self): sort=True ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_15(self): await self.assert_query_result( r''' @@ -765,6 +775,7 @@ async def test_edgeql_coalesce_dependent_17(self): sort=True ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_18(self): await self.assert_query_result( r''' @@ -779,6 +790,7 @@ async def test_edgeql_coalesce_dependent_18(self): sort=True ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_19(self): await self.assert_query_result( r''' @@ -888,6 +900,7 @@ async def test_edgeql_coalesce_dependent_20(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_21(self): await self.assert_query_result( r''' @@ -898,6 +911,7 @@ async def test_edgeql_coalesce_dependent_21(self): {'High', 'Low', 'Open', 'Closed'}, ) + @tb.needs_factoring async def test_edgeql_coalesce_dependent_22(self): await self.assert_query_result( r''' @@ -1048,6 +1062,7 @@ async def test_edgeql_coalesce_object_01(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_object_02(self): await self.assert_query_result( r''' @@ -1160,6 +1175,7 @@ async def test_edgeql_coalesce_object_06(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_object_07(self): await self.assert_query_result( r''' @@ -1412,6 +1428,7 @@ async def test_edgeql_coalesce_set_of_13(self): [], ) + @tb.needs_factoring async def test_edgeql_coalesce_set_of_nonempty_01(self): await self.con.execute( '''INSERT Publication { title := "1" }''') @@ -1451,6 +1468,7 @@ async def test_edgeql_coalesce_pointless_01(self): ["a"], ) + @tb.needs_factoring async def test_edgeql_coalesce_correlation_01(self): await self.assert_query_result( r''' @@ -1461,6 +1479,7 @@ async def test_edgeql_coalesce_correlation_01(self): ["Issue 160", "Issue 290", "Issue 390"], ) + @tb.needs_factoring async def test_edgeql_coalesce_correlation_02(self): await self.assert_query_result( r''' @@ -1497,6 +1516,7 @@ async def test_edgeql_coalesce_tuple_01(self): ] ) + @tb.needs_factoring async def test_edgeql_coalesce_tuple_02(self): await self.assert_query_result( r''' @@ -1514,6 +1534,7 @@ async def test_edgeql_coalesce_tuple_02(self): ) + @tb.needs_factoring async def test_edgeql_coalesce_tuple_03(self): await self.assert_query_result( r''' @@ -1530,6 +1551,7 @@ async def test_edgeql_coalesce_tuple_03(self): ] ) + @tb.needs_factoring async def test_edgeql_coalesce_tuple_04(self): await self.assert_query_result( r''' @@ -1546,6 +1568,7 @@ async def test_edgeql_coalesce_tuple_04(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_tuple_05(self): await self.assert_query_result( r''' @@ -1597,6 +1620,7 @@ async def test_edgeql_coalesce_tuple_07(self): ], ) + @tb.needs_factoring async def test_edgeql_coalesce_tuple_08(self): await self.con.execute(''' CREATE TYPE Foo { @@ -1706,6 +1730,7 @@ async def test_edgeql_coalesce_tuple_09(self): [2, 4], ) + @tb.needs_factoring async def test_edgeql_coalesce_overload_01(self): # first argument bool -> optional second arg await self.assert_query_result( @@ -1766,6 +1791,7 @@ async def test_edgeql_coalesce_overload_01(self): ]), ) + @tb.needs_factoring async def test_edgeql_coalesce_overload_02(self): # first argument int -> singleton second arg await self.assert_query_result( @@ -1969,3 +1995,7 @@ async def test_edgeql_coalesce_policy_link_01(self): ?? [is MultiRange].element_type.id, }; ''') + + +class TestEdgeQLCoalesceNoFactor(TestEdgeQLCoalesce): + NO_FACTOR = True diff --git a/tests/test_edgeql_data_migration.py b/tests/test_edgeql_data_migration.py index e7a7f4f4a0c..93e24d6be50 100644 --- a/tests/test_edgeql_data_migration.py +++ b/tests/test_edgeql_data_migration.py @@ -12924,16 +12924,15 @@ async def test_edgeql_migration_ai_10(self): with model := ( select schema::ObjectType { x := ( - select (.annotations, .annotations@value) - filter ( - .0.name - = 'ext::ai::embedding_model_max_batch_tokens' - ) + for ann in .annotations + select ann@value + filter ann.name + = 'ext::ai::embedding_model_max_batch_tokens' ) } filter .name = 'default::TestEmbeddingModel' ) - select model.x.1 + select model.x """, ['8191'], ) diff --git a/tests/test_edgeql_ddl.py b/tests/test_edgeql_ddl.py index 2ff5529798d..ceb26985f85 100644 --- a/tests/test_edgeql_ddl.py +++ b/tests/test_edgeql_ddl.py @@ -16320,6 +16320,10 @@ async def test_edgeql_ddl_dupe_link_storage_01(self): """) async def test_edgeql_ddl_scoping_future_01(self): + await self.con.execute(""" + configure session reset simple_scoping + """) + await self.con.execute(""" create type T; insert T; diff --git a/tests/test_edgeql_expr_aliases.py b/tests/test_edgeql_expr_aliases.py index 90309ddbe13..edabd2ca63a 100644 --- a/tests/test_edgeql_expr_aliases.py +++ b/tests/test_edgeql_expr_aliases.py @@ -117,7 +117,7 @@ async def test_edgeql_aliases_basic_03(self): await self.assert_query_result( r''' SELECT >scores - ORDER BY scores.name; + ORDER BY .0; ''', [ ['Alice', 100, 10], @@ -130,7 +130,7 @@ async def test_edgeql_aliases_basic_03(self): await self.assert_query_result( r''' SELECT >scores - ORDER BY scores.name; + ORDER BY .name; ''', [ {'name': 'Alice', 'points': 100, 'plays': 10}, @@ -537,7 +537,10 @@ async def test_edgeql_aliases_if_else_02(self): r""" # working with singletons SELECT - _ := 'ok' IF User.deck_cost < 19 ELSE User.deck.name + _ := ( + for u in User + select 'ok' IF u.deck_cost < 19 ELSE u.deck.name + ) ORDER BY _; """, [ @@ -558,8 +561,11 @@ async def test_edgeql_aliases_if_else_02(self): r""" # either result is a set, but the condition is a singleton SELECT - _ := User.deck.element IF User.deck_cost < 19 - ELSE User.deck.name + _ := ( + for u in User + select u.deck.element IF u.deck_cost < 19 + ELSE u.deck.name + ) ORDER BY _; """, [ @@ -639,6 +645,7 @@ async def test_edgeql_aliases_if_else_03(self): async def test_edgeql_aliases_if_else_04(self): await self.assert_query_result( r""" + FOR User in User SELECT 1 IF User.name[0] = 'A' ELSE 10 IF User.name[0] = 'B' ELSE @@ -650,14 +657,16 @@ async def test_edgeql_aliases_if_else_04(self): await self.assert_query_result( r""" + FOR User in User SELECT ( User.name, - sum( - 1 IF User.friends.name[0] = 'A' ELSE - 10 IF User.friends.name[0] = 'B' ELSE - 100 IF User.friends.name[0] = 'C' ELSE + sum(( + FOR f in User.friends SELECT + 1 IF f.name[0] = 'A' ELSE + 10 IF f.name[0] = 'B' ELSE + 100 IF f.name[0] = 'C' ELSE 0 - ), + )), ) ORDER BY .0; """, [['Alice', 110], ['Bob', 0], ['Carol', 0], ['Dave', 10]], @@ -666,8 +675,11 @@ async def test_edgeql_aliases_if_else_04(self): async def test_edgeql_aliases_if_else_05(self): await self.assert_query_result( r""" + SELECT ( + FOR Card in Card SELECT (Card.name, 'yes' IF Card.cost > 4 ELSE 'no') + ) ORDER BY .0; """, [ @@ -685,8 +697,11 @@ async def test_edgeql_aliases_if_else_05(self): await self.assert_query_result( r""" + SELECT ( + FOR Card in Card SELECT (Card.name, 'yes') IF Card.cost > 4 ELSE (Card.name, 'no') + ) ORDER BY .0; """, [ @@ -991,7 +1006,7 @@ async def test_edgeql_aliases_subqueries_01(self): (EarthOrFireCard.name) )) """, - [4] + [16] ) async def test_edgeql_aliases_subqueries_02(self): @@ -1002,7 +1017,7 @@ async def test_edgeql_aliases_subqueries_02(self): (SELECT EarthOrFireCard.name) )) """, - [4] + [16] ) async def test_edgeql_aliases_subqueries_03(self): @@ -1013,7 +1028,7 @@ async def test_edgeql_aliases_subqueries_03(self): (EarthOrFireCard.name) )) """, - [4] + [16] ) async def test_edgeql_aliases_subqueries_04(self): diff --git a/tests/test_edgeql_expressions.py b/tests/test_edgeql_expressions.py index 5b5a2c616af..3a5ff8c43dd 100644 --- a/tests/test_edgeql_expressions.py +++ b/tests/test_edgeql_expressions.py @@ -184,7 +184,6 @@ def get_test_items(**flags): class TestExpressions(tb.QueryTestCase): - NO_FACTOR = True SCHEMA = os.path.join(os.path.dirname(__file__), 'schemas', 'issues.esdl') diff --git a/tests/test_edgeql_filter.py b/tests/test_edgeql_filter.py index 3a55e932877..458ea24efea 100644 --- a/tests/test_edgeql_filter.py +++ b/tests/test_edgeql_filter.py @@ -32,7 +32,6 @@ class TestEdgeQLFilter(tb.QueryTestCase): SETUP = os.path.join(os.path.dirname(__file__), 'schemas', 'issues_filter_setup.edgeql') - @tb.ignore_warnings('more than one.* in a FILTER clause') async def test_edgeql_filter_two_scalar_conditions01(self): await self.assert_query_result( r''' @@ -40,10 +39,12 @@ async def test_edgeql_filter_two_scalar_conditions01(self): # time_estimate > 9000 and due_date on 2020/01/15. SELECT User{name} FILTER - User. 9000 - AND - User.'2020-01-15T00:00:00+00:00' + any(( + for issue in User. 9000 + AND + issue.due_date = '2020-01-15T00:00:00+00:00' + )) ORDER BY User.name; ''', # Only one Issue satisfies this and its owner is Yury. @@ -106,34 +107,6 @@ async def test_edgeql_filter_two_scalar_conditions03(self): [{'name': 'Yury'}], ) - @tb.ignore_warnings('more than one.* in a FILTER clause') - async def test_edgeql_filter_two_scalar_conditions04(self): - await self.assert_query_result( - r''' - # NOTE: semantically same as and01, but using OR, - # separate roots and explicit joining - # - # Find Users who own at least one Issue with simultaneously - # time_estimate > 9000 and due_date on 2020/01/15. - WITH - U2 := User - SELECT User{name} - FILTER - NOT ( - NOT EXISTS (User. 9000) - OR - NOT EXISTS (U2.'2020-01-15T00:00:00+00:00') - ) - AND - # making sure it's the same Issue in both sub-clauses - User. 9000 and due_date on 2020/01/15. - WITH - U2 := User - SELECT User{name} - FILTER - NOT ( - NOT EXISTS User. 0 - order by res.score desc + }) + filter .score > 0 + order by .score desc ''', [ { @@ -965,17 +965,17 @@ async def test_edgeql_fts_lang_05(self): # Use a property to define the language. await self.assert_query_result( r''' - with res := fts::search( + with res := (for DynamicLang in DynamicLang select fts::search( DynamicLang, 'clear pane', language := DynamicLang.lang, - ) - select res.object { + )) + select (for res in res select res.object { text, score := res.score - } - filter res.score > 0 - order by res.score desc + }) + filter .score > 0 + order by .score desc ''', [ {"text": "The window pane is clear", "score": 0.6079271}, @@ -985,17 +985,17 @@ async def test_edgeql_fts_lang_05(self): await self.assert_query_result( r''' - with res := fts::search( + with res := (for DynamicLang in DynamicLang select fts::search( DynamicLang, 'pain gain', language := DynamicLang.lang, - ) - select res.object { + )) + select (for res in res select res.object { text, score := res.score - } - filter res.score > 0 - order by res.score desc + }) + filter .score > 0 + order by .score desc ''', [ {"text": "No pain no gain", "score": 0.6079271}, @@ -1182,21 +1182,21 @@ async def test_edgeql_fts_weights_05(self): # Use weights to change search priority: weights from property await self.assert_query_result( r''' - with res := fts::search( + with res := (for Post in Post select fts::search( Post, 'random angry replying giraffes', language := 'eng', # Note that if the weight property is {}, the default weights # will be used. weights := [Post.weight_a, 0.7], - ) - select res.object { + )) + select (for res in res select res.object { title, body, score := res.score - } - filter res.score > 0 - order by res.score desc + }) + filter .score > 0 + order by .score desc ''', [ { diff --git a/tests/test_edgeql_functions.py b/tests/test_edgeql_functions.py index ff8d7ab75c2..a7136d5718a 100644 --- a/tests/test_edgeql_functions.py +++ b/tests/test_edgeql_functions.py @@ -32,7 +32,6 @@ class TestEdgeQLFunctions(tb.QueryTestCase): - NO_FACTOR = True SCHEMA = os.path.join(os.path.dirname(__file__), 'schemas', 'issues.esdl') diff --git a/tests/test_edgeql_functions_inline.py b/tests/test_edgeql_functions_inline.py index 7e2d9a313c4..72928d55d2c 100644 --- a/tests/test_edgeql_functions_inline.py +++ b/tests/test_edgeql_functions_inline.py @@ -24,7 +24,6 @@ class TestEdgeQLFunctionsInline(tb.QueryTestCase): - NO_FACTOR = True async def test_edgeql_functions_inline_basic_01(self): await self.con.execute(''' diff --git a/tests/test_edgeql_group.py b/tests/test_edgeql_group.py index 48081910cf3..d9288490454 100644 --- a/tests/test_edgeql_group.py +++ b/tests/test_edgeql_group.py @@ -27,6 +27,7 @@ class TestEdgeQLGroup(tb.QueryTestCase): '''These tests are focused on using the internal GROUP statement.''' + NO_FACTOR = False SCHEMA = os.path.join(os.path.dirname(__file__), 'schemas', 'issues.esdl') @@ -4060,4 +4061,5 @@ class TestEdgeQLGroupNoFactor(TestEdgeQLGroup): class TestEdgeQLGroupWarnFactor(TestEdgeQLGroup): + NO_FACTOR = False WARN_FACTOR = True diff --git a/tests/test_edgeql_insert.py b/tests/test_edgeql_insert.py index 37cabe9adf5..0ad78d65800 100644 --- a/tests/test_edgeql_insert.py +++ b/tests/test_edgeql_insert.py @@ -29,7 +29,7 @@ class TestInsert(tb.QueryTestCase): '''The scope of the tests is testing various modes of Object creation.''' - # NO_FACTOR = True + NO_FACTOR = False WARN_FACTOR = True INTERNAL_TESTMODE = False diff --git a/tests/test_edgeql_internal_group.py b/tests/test_edgeql_internal_group.py index 11a96e40f57..0613a9c96dd 100644 --- a/tests/test_edgeql_internal_group.py +++ b/tests/test_edgeql_internal_group.py @@ -303,7 +303,7 @@ async def test_edgeql_igroup_nested_01(self): await self.assert_query_result( r""" SELECT - R := ( + R := (for User in User union ( name := User.name, issues := array_agg( ( @@ -320,7 +320,7 @@ async def test_edgeql_igroup_nested_01(self): ORDER BY .status ) ) - ) + )) ORDER BY R.name; """, [ @@ -889,8 +889,9 @@ async def test_edgeql_igroup_by_multiple_03(self): IN Issue UNION ( # array_agg with ordering instead of sum - numbers := array_agg( - Issue.number ORDER BY Issue.number), + numbers := array_agg(( + select + _ := Issue.number ORDER BY _)), status := Stat, time_estimate := Est ?? 0 ) @@ -927,10 +928,10 @@ async def test_edgeql_igroup_by_multiple_04(self): IN Issue UNION ( # a couple of array_agg - numbers := array_agg( - Issue.number ORDER BY Issue.number), - watchers := array_agg( - Issue.watchers.name ORDER BY Issue.watchers.name), + numbers := array_agg((select + _ := Issue.number ORDER BY _)), + watchers := array_agg((select + _ := Issue.watchers.name ORDER BY _)), status := Stat, time_estimate := Est ?? 0 ) @@ -1014,8 +1015,8 @@ async def test_edgeql_igroup_by_multiple_06(self): BY Stat, X IN Issue UNION ( - numbers := array_agg( - Issue.number ORDER BY Issue.number), + numbers := array_agg((select + _ := Issue.number ORDER BY _)), watchers := count(DISTINCT Issue.watchers), status := Stat, cnt := count(DISTINCT Issue), diff --git a/tests/test_edgeql_json.py b/tests/test_edgeql_json.py index 9deddd78631..00d924fceaf 100644 --- a/tests/test_edgeql_json.py +++ b/tests/test_edgeql_json.py @@ -824,10 +824,7 @@ async def test_edgeql_json_object_unpack_05(self): "w": 2 }')) ) - SELECT - q.1.1 - ORDER BY - q.1.0; + SELECT (SELECT q ORDER BY q.1.0).1.1; ''', [1, 2] ) diff --git a/tests/test_edgeql_linkprops.py b/tests/test_edgeql_linkprops.py index 91722823795..0c9f1773273 100644 --- a/tests/test_edgeql_linkprops.py +++ b/tests/test_edgeql_linkprops.py @@ -259,7 +259,6 @@ async def test_edgeql_props_basic_02(self): ] ) - @tb.ignore_warnings('more than one.* in a FILTER clause') async def test_edgeql_props_basic_03(self): await self.assert_query_result( r''' @@ -272,7 +271,7 @@ async def test_edgeql_props_basic_03(self): cost, @count } ORDER BY @count DESC THEN .name ASC - } FILTER .deck.cost = .deck@count + } FILTER any((for d in .deck select d.cost = d@count)) ORDER BY .name; ''', [ @@ -433,7 +432,6 @@ async def test_edgeql_props_cross_01(self): ] ) - @tb.ignore_warnings('more than one.* in a FILTER clause') async def test_edgeql_props_cross_02(self): await self.assert_query_result( r''' @@ -442,39 +440,11 @@ async def test_edgeql_props_cross_02(self): name, same := EXISTS ( SELECT User - FILTER - Card.cost = User.deck@count AND - Card = User.deck - ) - } - ORDER BY .name; - ''', - [ - {'name': 'Bog monster', 'same': False}, - {'name': 'Djinn', 'same': False}, - {'name': 'Dragon', 'same': False}, - {'name': 'Dwarf', 'same': False}, - {'name': 'Giant eagle', 'same': False}, - {'name': 'Giant turtle', 'same': True}, - {'name': 'Golem', 'same': True}, - {'name': 'Imp', 'same': False}, - {'name': 'Sprite', 'same': False}, - ] - ) - - @tb.ignore_warnings('more than one.* in a FILTER clause') - async def test_edgeql_props_cross_03(self): - await self.assert_query_result( - r''' - # get cards that have the same count in some deck as their cost - SELECT Card { - name, - same := EXISTS ( - SELECT - User - FILTER - Card.cost = User.deck@count AND - Card = User.deck + FILTER any (( + FOR User IN User FOR deck IN User.deck SELECT + Card.cost = deck@count AND + Card = deck + )) ) } ORDER BY .name; @@ -940,7 +910,10 @@ async def test_edgeql_props_agg_01(self): await self.assert_query_result( r''' - SELECT _ := (sum(User.deck@count), User.name) + SELECT _ := ( + FOR User in User + SELECT (sum(User.deck@count), User.name) + ) ORDER BY _; ''', [ @@ -1182,7 +1155,9 @@ async def test_edgeql_props_link_union_03(self): async def test_edgeql_props_back_01(self): await self.assert_query_result( """ - with X1 := (Card { z := (.